API Reference
bincode
A compact binary encoder and decoder for Rust using serde, with configurable options.
Official Documentation ↗CompatibilityThis documentation covers version
v1.3. Check the official docs for the latest API surface.Installation
cargo
cargo add bincodeMethods
No methods match this filter.
bincode serializes serde types to a compact, non-self-describing binary format.
Key Features
- Compact non-self-describing encoding
- Configurable endianness and limits
- Fast serde based serialization
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The official API reference declares the following error types:
bincode::error::ErrorKind(enum) — official text: “pub enum ErrorKind { Io(Error), InvalidUtf8Encoding(Utf8Error), InvalidBoolEncoding(u8), InvalidCharEncoding, InvalidTagEncoding(usize), DeserializeAnyNotSupported, SizeLimit, SequenceMustHaveLength, Custom(String), }” (source: https://docs.rs/bincode/1.3.3/bincode/error/enum.ErrorKind.html, fetched 2026-11-08T16:01:12.9137723+08:00)
API reference evidence
Fetched from official sources on 2026-11-08T16:01:12.9137723+08:00 via WebFetch docs.rs bincode 1.3.3 fn.serialize/fn.deserialize/fn.options/error::ErrorKind 页,并核对 latest 模块页(2.0.1).
bincode::serialize→ signature from https://docs.rs/bincode/1.3.3/bincode/fn.serialize.html; official text: “pub fn serialize(value: &T) -> Result<Vec > where T: Serialize + ?Sized, Serializes a serializable object into a Vecof bytes using the default configuration.”bincode::deserialize→ signature from https://docs.rs/bincode/1.3.3/bincode/fn.deserialize.html; official text: “pub fn deserialize<’a, T>(bytes: &’a [u8]) -> Resultwhere T: Deserialize<’a>, Deserializes a slice of bytes into an instance of Tusing the default configuration.”
FAQ
- Can I decode untrusted input safely?
- Only with a size limit. Use with_limit on the options, since the decoder generally trusts the byte length.
- Is the format stable across versions?
- Not guaranteed across major versions. Pin the version or store a format tag with your data.
- Why is output smaller than JSON?
- It omits field names and type tags, writing values only, which also makes it faster to parse.
Report a problem with this API docOpens a pre-filled issue on GitHub.