| Crates.io | actix-bincode |
| lib.rs | actix-bincode |
| version | 0.4.0 |
| created_at | 2022-11-11 01:23:45.07423+00 |
| updated_at | 2025-06-28 16:00:00.345094+00 |
| description | Bincode extractor for Actix Web |
| homepage | |
| repository | https://github.com/aalhitennf/actix-bincode |
| max_upload_size | |
| id | 712559 |
| size | 60,342 |
Bincode payload extractor for Actix Web
use actix_bincode::Bincode;
use bincode::{Decode, Encode};
#[derive(Decode, Encode)]
pub struct Object {
pub num: i32,
pub text: String,
}
async fn index(object: Bincode<Object>) -> HttpResponse {
println!("num: {}", object.num);
println!("text: {}", object.text);
let config = bincode::config::standard();
let body = bincode::encode_to_vec(object.into_inner(), config).unwrap();
HttpResponse::Ok().body(body)
}
use actix_bincode::BincodeSerde;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)]
pub struct Object {
pub num: i32,
pub text: String,
}
async fn index(object: BincodeSerde<Object>) -> HttpResponse {
println!("num: {}", object.num);
println!("text: {}", object.text);
let config = bincode::config::standard();
let body = bincode::serde::encode_to_vec(object.into_inner(), config).unwrap();
HttpResponse::Ok().body(body)
}
Extractor tries to read configuration from actix app data, and defaults to standard if none present:
let config = bincode::config::standard().with_big_endian();
let app = App::new().app_data(config);
This project is licensed under