{"id":13439236,"url":"https://github.com/bincode-org/bincode","last_synced_at":"2025-05-13T16:03:27.222Z","repository":{"id":20843776,"uuid":"24130045","full_name":"bincode-org/bincode","owner":"bincode-org","description":"A binary encoder / decoder implementation in Rust.","archived":false,"fork":false,"pushed_at":"2025-04-17T20:18:18.000Z","size":1094,"stargazers_count":2967,"open_issues_count":31,"forks_count":286,"subscribers_count":27,"default_branch":"trunk","last_synced_at":"2025-05-06T16:06:43.725Z","etag":null,"topics":["binary","encoding","rust","serialization"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bincode-org.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"bincode","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"custom":null}},"created_at":"2014-09-17T04:38:03.000Z","updated_at":"2025-05-06T13:36:20.000Z","dependencies_parsed_at":"2024-05-28T10:10:06.604Z","dependency_job_id":"74e535ac-0439-4cb4-824a-60186d0e5480","html_url":"https://github.com/bincode-org/bincode","commit_stats":{"total_commits":574,"total_committers":103,"mean_commits":5.572815533980583,"dds":0.6689895470383276,"last_synced_commit":"980f63812707def85bf51c67956ebf313eb74f32"},"previous_names":["tyoverby/bincode","servo/bincode"],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bincode-org%2Fbincode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bincode-org%2Fbincode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bincode-org%2Fbincode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bincode-org%2Fbincode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bincode-org","download_url":"https://codeload.github.com/bincode-org/bincode/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253342299,"owners_count":21893558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary","encoding","rust","serialization"],"created_at":"2024-07-31T03:01:12.215Z","updated_at":"2025-05-13T16:03:27.171Z","avatar_url":"https://github.com/bincode-org.png","language":"Rust","readme":"# Bincode\n\u003cimg align=\"right\" src=\"./logo.svg\" /\u003e\n\n[![CI](https://github.com/bincode-org/bincode/workflows/CI/badge.svg)](https://github.com/bincode-org/bincode/actions)\n[![](https://img.shields.io/crates/v/bincode.svg)](https://crates.io/crates/bincode)\n[![](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\u003c!-- [![](https://img.shields.io/badge/bincode-rustc_1.41.1+-lightgray.svg)](https://blog.rust-lang.org/2020/02/27/Rust-1.41.1.html) --\u003e\n[![Matrix](https://img.shields.io/matrix/bincode:matrix.org?label=Matrix%20Chat)](https://matrix.to/#/#bincode:matrix.org)\n\nA compact encoder / decoder pair that uses a binary zero-fluff encoding scheme.\nThe size of the encoded object will be the same or smaller than the size that\nthe object takes up in memory in a running Rust program.\n\nIn addition to exposing two simple functions\n(one that encodes to `Vec\u003cu8\u003e`, and one that decodes from `\u0026[u8]`),\nbinary-encode exposes a Reader/Writer API that makes it work\nperfectly with other stream-based APIs such as Rust files, network streams,\nand the [flate2-rs](https://github.com/rust-lang/flate2-rs) compression\nlibrary.\n\n## [API Documentation](https://docs.rs/bincode/)\n\n## Bincode in the Wild\n\n* [google/tarpc](https://github.com/google/tarpc): Bincode is used to serialize and deserialize networked RPC messages.\n* [servo/webrender](https://github.com/servo/webrender): Bincode records WebRender API calls for record/replay-style graphics debugging.\n* [servo/ipc-channel](https://github.com/servo/ipc-channel): IPC-Channel uses Bincode to send structs between processes using a channel-like API.\n* [ajeetdsouza/zoxide](https://github.com/ajeetdsouza/zoxide): zoxide uses Bincode to store a database of directories and their access frequencies on disk.\n\n## Example\n\n```rust\nuse bincode::{config, Decode, Encode};\n\n#[derive(Encode, Decode, PartialEq, Debug)]\nstruct Entity {\n    x: f32,\n    y: f32,\n}\n\n#[derive(Encode, Decode, PartialEq, Debug)]\nstruct World(Vec\u003cEntity\u003e);\n\nfn main() {\n    let config = config::standard();\n\n    let world = World(vec![Entity { x: 0.0, y: 4.0 }, Entity { x: 10.0, y: 20.5 }]);\n\n    let encoded: Vec\u003cu8\u003e = bincode::encode_to_vec(\u0026world, config).unwrap();\n\n    // The length of the vector is encoded as a varint u64, which in this case gets collapsed to a single byte\n    // See the documentation on varint for more info for that.\n    // The 4 floats are encoded in 4 bytes each.\n    assert_eq!(encoded.len(), 1 + 4 * 4);\n\n    let (decoded, len): (World, usize) = bincode::decode_from_slice(\u0026encoded[..], config).unwrap();\n\n    assert_eq!(world, decoded);\n    assert_eq!(len, encoded.len()); // read all bytes\n}\n```\n\n## Specification\n\nBincode's format is specified in [docs/spec.md](https://github.com/bincode-org/bincode/blob/trunk/docs/spec.md).\n\n## FAQ\n\n### Is Bincode suitable for storage?\n\nThe encoding format is stable, provided the same configuration is used.\nThis should ensure that later versions can still read data produced by a previous versions of the library if no major version change\nhas occurred.\n\nBincode 1 and 2 are completely compatible if the same configuration is used.\n\nBincode is invariant over byte-order, making an exchange between different\narchitectures possible. It is also rather space efficient, as it stores no\nmetadata like struct field names in the output format and writes long streams of\nbinary data without needing any potentially size-increasing encoding.\n\nAs a result, Bincode is suitable for storing data. Be aware that it does not\nimplement any sort of data versioning scheme or file headers, as these\nfeatures are outside the scope of this crate.\n\n### Is Bincode suitable for untrusted inputs?\n\nBincode attempts to protect against hostile data. There is a maximum size\nconfiguration available (`Configuration::with_limit`), but not enabled in the\ndefault configuration. Enabling it causes pre-allocation size to be limited to\nprevent against memory exhaustion attacks.\n\nDeserializing any incoming data will not cause undefined behavior or memory\nissues, assuming that the deserialization code for the struct is safe itself.\n\nBincode can be used for untrusted inputs in the sense that it will not create a\nsecurity issues in your application, provided the configuration is changed to enable a\nmaximum size limit. Malicious inputs will fail upon deserialization.\n\n### What is Bincode's MSRV (minimum supported Rust version)?\n\nBincode 2.0 has an MSRV of 1.85.0. Any changes to the MSRV are considered a breaking change for semver purposes, except when certain features are enabled. Features affecting MSRV are documented in the crate root.\n\n### Why does bincode not respect `#[repr(u8)]`?\n\nBincode will encode enum variants as a `u32`. If you're worried about storage size, we can recommend enabling `Configuration::with_variable_int_encoding()`. This option is enabled by default with the `standard` configuration. In this case enum variants will almost always be encoded as a `u8`.\n\nCurrently we have not found a compelling case to respect `#[repr(...)]`. You're most likely trying to interop with a format that is similar-but-not-quite-bincode. We only support our own protocol ([spec](https://github.com/bincode-org/bincode/blob/trunk/docs/spec.md)).\n\nIf you really want to use bincode to encode/decode a different protocol, consider implementing `Encode` and `Decode` yourself. `bincode-derive` will output the generated implementation in `target/generated/bincode/\u003cname\u003e_Encode.rs` and `target/generated/bincode/\u003cname\u003e_Decode.rs` which should get you started.\n","funding_links":["https://ko-fi.com/bincode"],"categories":["Libraries","Others","Rust","库 Libraries","Uncategorized"],"sub_categories":["Encoding","编码 Encoding","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbincode-org%2Fbincode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbincode-org%2Fbincode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbincode-org%2Fbincode/lists"}