5 releases

0.1.4 Sep 29, 2020
0.1.3 Sep 29, 2020
0.1.2 Sep 29, 2020
0.1.1 Sep 28, 2020
0.1.0 Sep 28, 2020

#78 in #cbor

MIT/Apache

24KB
550 lines

Overview

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

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.

Pull requests are welcome.


lib.rs:

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 })
}

Dependencies

~29MB
~628K SLoC