{"id":29068845,"url":"https://github.com/aspectron/manual-serializer","last_synced_at":"2025-06-27T11:09:31.079Z","repository":{"id":64860465,"uuid":"575269502","full_name":"aspectron/manual-serializer","owner":"aspectron","description":"Rust serializer crate designed for manual processing of data buffers","archived":false,"fork":false,"pushed_at":"2023-03-20T01:55:14.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-04T11:34:31.349Z","etag":null,"topics":["rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aspectron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-07T05:59:25.000Z","updated_at":"2023-03-15T13:13:47.000Z","dependencies_parsed_at":"2023-01-30T01:45:37.675Z","dependency_job_id":null,"html_url":"https://github.com/aspectron/manual-serializer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aspectron/manual-serializer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspectron%2Fmanual-serializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspectron%2Fmanual-serializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspectron%2Fmanual-serializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspectron%2Fmanual-serializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aspectron","download_url":"https://codeload.github.com/aspectron/manual-serializer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspectron%2Fmanual-serializer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262244912,"owners_count":23281029,"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":["rust"],"created_at":"2025-06-27T11:09:29.336Z","updated_at":"2025-06-27T11:09:31.057Z","avatar_url":"https://github.com/aspectron.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `manual-serializer`\n\nSerialization tools for manual buffer processing\n\n[![Crates.io](https://img.shields.io/crates/l/manual-serializer.svg?maxAge=2592000)](https://crates.io/crates/manual-serializer)\n[![Crates.io](https://img.shields.io/crates/v/manual-serializer.svg?maxAge=2592000)](https://crates.io/crates/manual-serializer)\n\n\n### Overview\n\nThis crate is useful when you need to quickly and manually extract data structures from u8 buffers. This can be useful when parsing 3rd-party custom binary data files that have complex data layout making it hard to use existing serializers or structs with `#[repr(packed)]` (as those can be difficult to deal with due to alignment issues).\n\nBeside the basic functions for loading and storing u8,u16,u32,u64 primitives, this serializer provides the following helpers:\n* Functions for handling u16le arrays\n* Functions for extracting u16 zero terminated strings (such as `PCWSTR` - used in Windows data structures)\n* Alignment functions to position the cursor on N-byte boundaries (such as `align_u32()`)\n\nNOTE: This crate currently supports only *little-endian* encoded primitives.\n\n### Example\n\n```rust\n\n#[derive(Debug)]\npub struct Header {\n    pub magic : usize,\n    pub version : u16,\n    pub payload : Vec\u003cu8\u003e,\n}\n\nimpl TrySerialize for Header {\n    type Error = Error;\n    fn try_serialize(\u0026self, dest: \u0026mut Serializer) -\u003e Result\u003c()\u003e {\n        dest.try_align_u32()?;\n        dest.try_store_u16le(self.magic as u16)?;\n        dest.try_store_u16le(self.version)?;\n        dest.try_store_u32le(self.payload.len() as u32)?;\n        dest.try_store_u8_slice(\u0026self.payload)?;\n        Ok(())\n    }\n}\n\nfn store() {\n    let mut dest = Serializer::new(4096);\n    let header = Header::default();\n    dest.try_store(\u0026header)?;\n}\n\nimpl TryDeserialize for Header {\n    type Error = Error;\n\n    fn try_deserialize(src: \u0026mut Deserializer) -\u003e Result\u003cHeader\u003e {\n        src.try_align_u32()?;\n\n        let magic = src.try_load_u16le()? as usize;\n        let version = src.try_load_u16le()?;\n        let payload_length = src.try_load_u32le()? as usize;\n        let payload = src.try_load_u8_vec(payload_length)?.to_vec()?;\n\n        Ok(Header{magic, version, payload})\n    }\n}\n\nfn load(data: \u0026[u8], offset: usize) -\u003e Result\u003c(u32,Header)\u003e{\n    let mut src = Deserializer::new(data);\n    src.offset(offset)?;\n    let signature = src.try_load_u32le()?;\n    let header: Header = src.try_load()?;\n    Ok((signature,header))\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspectron%2Fmanual-serializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faspectron%2Fmanual-serializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspectron%2Fmanual-serializer/lists"}