diff --git a/Cargo.toml b/Cargo.toml index 8c179b2..9842bc4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-cbor" -version = "0.1.3" +version = "0.1.4" authors = ["noah "] edition = "2018" description = "CBOR support for Actix-Web" diff --git a/README.md b/README.md index 711bf61..c4f9507 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,25 @@ This crate provides an extractor for working with CBOR. It closely mirrors the API for JSON extraction within Actix-Web, and in fact borrows most of it's code from Actix-Web. +# Example +```rust +use actix_cbor::Cbor; + +struct User { + name: String, +} +struct Greeting { + inner: String, +} + +#[get("/users/hello")] +pub async fn greet_user(user: Cbor) -> Cbor { + let name: &str = &user.name; + let inner: String = format!("Hello {}!", name); + Cbor(Greeting { inner }) +} +``` + # Contributing If you have a bug report or feature request, create a new GitHub issue. diff --git a/src/lib.rs b/src/lib.rs index 51637ce..b75d321 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,22 @@ +//! # Example +//! ``` +//! use actix_cbor::Cbor; +//! +//! struct User { +//! name: String, +//! } +//! struct Greeting { +//! inner: String, +//! } +//! +//! #[get("/users/hello")] +//! pub async fn greet_user(user: Cbor) -> Cbor { +//! let name: &str = &user.name; +//! let inner: String = format!("Hello {}!", name); +//! Cbor(Greeting { inner }) +//! } +//! ``` + #[cfg(test)] #[macro_use] extern crate serde;