{"id":16847225,"url":"https://github.com/koute/speedy","last_synced_at":"2025-05-14T12:12:01.285Z","repository":{"id":27321180,"uuid":"113369037","full_name":"koute/speedy","owner":"koute","description":"A fast binary serialization framework","archived":false,"fork":false,"pushed_at":"2024-10-16T08:22:41.000Z","size":311,"stargazers_count":396,"open_issues_count":44,"forks_count":48,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-12T04:49:15.613Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koute.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"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}},"created_at":"2017-12-06T21:27:12.000Z","updated_at":"2025-04-29T04:56:36.000Z","dependencies_parsed_at":"2024-01-14T12:47:38.465Z","dependency_job_id":"bce19739-9387-426e-8d3f-75d376784843","html_url":"https://github.com/koute/speedy","commit_stats":{"total_commits":264,"total_committers":9,"mean_commits":"29.333333333333332","dds":0.04166666666666663,"last_synced_commit":"e8130d460ed12a75e96e56ffd521adfae6a1f546"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koute%2Fspeedy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koute%2Fspeedy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koute%2Fspeedy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koute%2Fspeedy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koute","download_url":"https://codeload.github.com/koute/speedy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140768,"owners_count":22021220,"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":[],"created_at":"2024-10-13T13:07:08.345Z","updated_at":"2025-05-14T12:12:01.246Z","avatar_url":"https://github.com/koute.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A fast binary serialization framework\n\n[![Documentation](https://docs.rs/speedy/badge.svg)](https://docs.rs/speedy/*/speedy/)\n\nThe goal of this crate is to provide fast, simple and easy binary serialization.\n\n## Benchmarks\n\nSee [rust_serialization_benchmark](https://github.com/djkoloski/rust_serialization_benchmark) for benchmarks.\n\n## Example\n\n```rust\nuse std::borrow::Cow;\nuse speedy::{Readable, Writable, Endianness};\n\n#[derive(PartialEq, Debug, Readable, Writable)]\nenum Enum {\n    A,\n    B,\n    C,\n}\n\n#[derive(PartialEq, Debug, Readable, Writable)]\nstruct Struct\u003c 'a \u003e {\n    number: u64,\n    string: String,\n    vector: Vec\u003c u8 \u003e,\n    cow: Cow\u003c 'a, [i64] \u003e,\n    float: f32,\n    enumeration: Enum\n}\n\nfn main() {\n    let original = Struct {\n        number: 0x12345678ABCDEF00,\n        string: \"A totally pointless string\".to_owned(),\n        vector: vec![ 1, 2, 3 ],\n        cow: Cow::Borrowed( \u0026[ 4, 5, 6 ] ),\n        float: 3.1415,\n        enumeration: Enum::C\n    };\n\n    let bytes = original.write_to_vec().unwrap();\n    let deserialized: Struct =\n        Struct::read_from_buffer( \u0026bytes ).unwrap();\n\n    assert_eq!( original, deserialized );\n}\n```\n\n## Supported types\n\nOut-of-box the following types are supported:\n\n|                    Type |                            Serialized as |\n| ----------------------- | ---------------------------------------- |\n|                    `u8` |                                    as-is |\n|                   `u16` |                                    as-is |\n|                   `u32` |                                    as-is |\n|                   `u64` |                                    as-is |\n|                 `usize` |                                    `u64` |\n|                    `i8` |                                    as-is |\n|                   `i16` |                                    as-is |\n|                   `i32` |                                    as-is |\n|                   `i64` |                                    as-is |\n|                   `f32` |                                    as-is |\n|                   `f64` |                                    as-is |\n|                  `bool` |                  `u8`, either `0` or `1` |\n|                  `char` |                                    `u32` |\n|                `String` |             `{length: u32, bytes: [u8]}` |\n|          `Cow\u003c'a, str\u003e` |             `{length: u32, bytes: [u8]}` |\n|                `Vec\u003cT\u003e` |             `{length: u32, values: [T]}` |\n|          `Cow\u003c'a, [T]\u003e` |             `{length: u32, values: [T]}` |\n|         `HashMap\u003cK, V\u003e` |          `{length: u32, values: [K, V]}` |\n|        `BTreeMap\u003cK, V\u003e` |          `{length: u32, values: [K, V]}` |\n|            `HashSet\u003cT\u003e` |             `{length: u32, values: [T]}` |\n|           `BTreeSet\u003cT\u003e` |             `{length: u32, values: [T]}` |\n|              `Range\u003cT\u003e` |                                 `(T, T)` |\n|     `RangeInclusive\u003cT\u003e` |                                 `(T, T)` |\n|             `Option\u003cT\u003e` |                    `(1_u8, T)` or `0_u8` |\n|          `Result\u003cT, E\u003e` |               `(1_u8, T)` or `(0_u8, E)` |\n|                    `()` |                                  nothing |\n|                   `(T)` |                                    as-is |\n|                `(T, T)` |                                    as-is |\n|            `(T, .., T)` |                                    as-is |\n|                 `enum`s |                 `{tag: u32, variant: T}` |\n|              `AtomicU8` |                                     `u8` |\n|              `AtomicI8` |                                     `i8` |\n|             `AtomicU16` |                                    `u16` |\n|             `AtomicI16` |                                    `i16` |\n|             `AtomicU32` |                                    `u32` |\n|             `AtomicI32` |                                    `i32` |\n|             `AtomicU64` |                                    `u64` |\n|             `AtomicI64` |                                    `i64` |\n|            `NonZeroU32` |                                    `u32` |\n|    `std::net::Ipv4Addr` |                                    `u32` |\n|    `std::net::Ipv6Addr` |                                   `u128` |\n|      `std::net::IpAddr` |    `{is_ipv4: u8, value: {u32 or u128}}` |\n|   `std::time::Duration` |         `{secs: u64, subsec_nanos: u32}` |\n| `std::time::SystemTime` | `std::time::Duration` since `UNIX_EPOCH` |\n|            `uuid::Uuid` |                               `[u8; 16]` |\n\nThese are stable and will not change in the future.\n\n## Field attributes\n\n### `#[speedy(length = $expr)]`\n\nCan be used on most standard containers to specify the field's length.\nCan refer to any of the previous fields.\n\nFor example:\n\n```rust\nuse speedy::{Readable, Writable};\n\n#[derive(Readable, Writable)]\nstruct Struct {\n    byte_count: u8,\n    #[speedy(length = byte_count / 4)]\n    data: Vec\u003c u32 \u003e\n}\n```\n\nBefore serializing you need to make sure that whatever is set as `length`\nis equal to the `.len()` of the field; if it's not then you will get\nan error when trying to serialize it.\n\nSetting this attribute changes the serialization format as follows:\n\n\n|             Type |                Serialized as |\n| ---------------- | ---------------------------- |\n|         `Vec\u003cT\u003e` |                        `[T]` |\n|   `Cow\u003c'a, [T]\u003e` |                        `[T]` |\n|         `String` |                       `[u8]` |\n|   `Cow\u003c'a, str\u003e` |                       `[u8]` |\n|  `HashMap\u003cK, V\u003e` |                     `[K, V]` |\n| `BTreeMap\u003cK, V\u003e` |                     `[K, V]` |\n|     `HashSet\u003cT\u003e` |                        `[T]` |\n|    `BTreeSet\u003cT\u003e` |                        `[T]` |\n\n### `#[speedy(length_type = $ty)]`\n\nCan be used to specify the exact size of the implicit length field of a container\nas it is read or written.\n\nPossible values:\n  - `u7` (same as u8, but restricted to 7 bits for `u64_varint` compatibility)\n  - `u8`\n  - `u16`\n  - `u32` (default)\n  - `u64_varint`\n\n### `#[speedy(varint)]`\n\nCan be used only on `u64` fields. Forces the field to be serialized as a varint.\n\n### `#[speedy(skip)]`\n\nSkips a given field when reading and writing.\n\n### `#[speedy(default_on_eof)]`\n\nIf an EOF is encountered when reading this field its value will be set\nto the default value for its type and the EOF will be ignored.\n\n### `#[speedy(constant_prefix = $expr)]`\n\nSpecifies a static string of bytes which will be written or has to be present\nwhen reading before a given field.\n\n## Enum attributes\n\n### `#[speedy(tag_type = $ty)]`\n\nCan be used to specify the exact size of the enum's tag as it is read or written.\n\nPossible values:\n  - `u7` (same as u8, but restricted to 7 bits for `u64_varint` compatibility)\n  - `u8`\n  - `u16`\n  - `u32` (default)\n  - `u64_varint`\n\n### `#[speedy(peek_tag)]`\n\nAn enum marked with this attribute will not consume its tag value when reading\nfrom a stream, nor will it write its own tag when writing.\n\n## Enum variant attributes\n\n### `#[speedy(tag = $expr)]`\n\nSpecifies a preset tag value to be used for a given enum variant.\n\n## License\n\nLicensed under either of\n\n  * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n  * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoute%2Fspeedy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoute%2Fspeedy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoute%2Fspeedy/lists"}