From 7d8858f57c07de589229683ffce98d9700492be0 Mon Sep 17 00:00:00 2001 From: asonix Date: Fri, 8 Dec 2023 23:17:42 -0600 Subject: [PATCH] Add library and deadline documentation --- releases/0.5.0.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/releases/0.5.0.md b/releases/0.5.0.md index acfcb5b..eb3551d 100644 --- a/releases/0.5.0.md +++ b/releases/0.5.0.md @@ -295,9 +295,45 @@ codec, this can be enabled by removing the video_codec and audio_codec configura ### Library API Changes +The library API for pict-rs has changed from 0.4. It now follows a "fluent programming" pattern of +chaining methods to configure and launch the service from within another application. Documentation +for the new library API can be found on [docs.rs](https://docs.rs/pict-rs) + +For most cases, using pict-rs' `ConfigSource` as the entrypoint is recommended. + +As a quick example, +```rust +#[tokio::main] +async fn main() -> Result<(), Box> { + pict_rs::ConfigSource::memory(serde_json::json!({ + "server": { + "address": "127.0.0.1:8080" + }, + "repo": { + "type": "sled", + "path": "./sled-repo" + }, + "store": { + "type": "filesystem", + "path": "./files" + } + })) + .init::<&str>(None)? + .run_on_localset() + .await?; + + Ok(()) +} +``` + ### Reject Malformed Deadlines +pict-rs supports setting a request deadline with the `X-Request-Deadline` header, where the value is +a unix timestamp in nanoseconds. In pict-rs 0.4, requests with deadlines that could not be parsed +were treated as requests without deadlines. in pict-rs 0.5 a malformed deadline will cause the +request to be rejected with a 400 Bad Request error. + ### Logging Verbosity