A binary encoder/decoder for Rust
See the codeA binary encoder/decoder with the following goals:
In contrast, these are non-goals:
See rust_serialization_benchmark for benchmarks.
use bitcode::{Encode, Decode};
#[derive(Encode, Decode, PartialEq, Debug)]
struct Foo<'a> {
x: u32,
y: &'a str,
}
let original = Foo {
x: 10,
y: "abc",
};
let encoded: Vec<u8> = bitcode::encode(&original); // No error
let decoded: Foo<'_> = bitcode::decode(&encoded).unwrap();
assert_eq!(original, decoded);
See the instructions here!
serdeA serde integration is gated behind the "serde" feature flag. Click here to learn more.
#![no_std]All std-only functionality is gated behind the (default) "std" feature.
alloc is required.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
(top 24 of 28)
609 followers · starred Mar 2024
6,711 followers · starred May 2024
478 followers · starred Dec 2025
431 followers · starred May 2024
A binary encoder/decoder for Rust
See the codeA binary encoder/decoder with the following goals:
In contrast, these are non-goals:
See rust_serialization_benchmark for benchmarks.
use bitcode::{Encode, Decode};
#[derive(Encode, Decode, PartialEq, Debug)]
struct Foo<'a> {
x: u32,
y: &'a str,
}
let original = Foo {
x: 10,
y: "abc",
};
let encoded: Vec<u8> = bitcode::encode(&original); // No error
let decoded: Foo<'_> = bitcode::decode(&encoded).unwrap();
assert_eq!(original, decoded);
See the instructions here!
serdeA serde integration is gated behind the "serde" feature flag. Click here to learn more.
#![no_std]All std-only functionality is gated behind the (default) "std" feature.
alloc is required.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
(top 24 of 28)
609 followers · starred Mar 2024
6,711 followers · starred May 2024
478 followers · starred Dec 2025
431 followers · starred May 2024