Skip to content

Commit

Permalink
Documentation improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah-Kennedy committed Sep 29, 2020
1 parent 6499b36 commit 8662c5e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "actix-cbor"
version = "0.1.3"
version = "0.1.4"
authors = ["noah <[email protected]>"]
edition = "2018"
description = "CBOR support for Actix-Web"
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<User>) -> Cbor<Greeting> {
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.

Expand Down
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<User>) -> Cbor<Greeting> {
//! let name: &str = &user.name;
//! let inner: String = format!("Hello {}!", name);
//! Cbor(Greeting { inner })
//! }
//! ```
#[cfg(test)]
#[macro_use]
extern crate serde;
Expand Down

0 comments on commit 8662c5e

Please sign in to comment.