{"id":20406288,"url":"https://github.com/techassi/binbuf","last_synced_at":"2026-06-11T09:31:40.242Z","repository":{"id":118014201,"uuid":"539005157","full_name":"Techassi/binbuf","owner":"Techassi","description":"A small library to work with binary (network) data in Rust","archived":false,"fork":false,"pushed_at":"2024-09-26T07:57:26.000Z","size":159,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T02:20:17.270Z","etag":null,"topics":["binary-data","network-programming","rust"],"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/Techassi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-09-20T13:32:23.000Z","updated_at":"2024-09-26T07:57:28.000Z","dependencies_parsed_at":"2025-01-15T11:50:48.159Z","dependency_job_id":null,"html_url":"https://github.com/Techassi/binbuf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Techassi/binbuf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techassi%2Fbinbuf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techassi%2Fbinbuf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techassi%2Fbinbuf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techassi%2Fbinbuf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Techassi","download_url":"https://codeload.github.com/Techassi/binbuf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techassi%2Fbinbuf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34192870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-data","network-programming","rust"],"created_at":"2024-11-15T05:16:14.499Z","updated_at":"2026-06-11T09:31:40.222Z","avatar_url":"https://github.com/Techassi.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# binbuf\n\nbinbuf (short for *binary buffers*) is a small library to work with binary (network) data in Rust. Just add\n`binbuf::prelude::*` to your imports. This imports the most important parts of the library.\n\n## Reading from `Reader`\n\n### Reading basic types\n\nThe library provides multiple methods to read basic data types like `u8`, `u16`, `u32`, `u64`, `u128`,\n`Ipv4Addr`, and `Ipv6Addr` in big and little-endian byte order.\n\n```rust\nlet b = vec![69, 88, 65, 77, 80, 76, 69, 33];\nlet mut b = Reader::new(b.as_slice());\n\nmatch u16::read::\u003cBigEndian\u003e(\u0026mut b) {\n    Ok(n) =\u003e assert_eq!(n, 17752),\n    Err(err) =\u003e panic!(\"{}\", err),\n}\n```\n\n### Reading structs and enums\n\nTo read custom data structs or enums, we can use the derive macro `#[derive(Read)]` to annotate the structs.\n\n```rust\n#[derive(Read)]\nstruct Data {\n    inner: u16,\n}\n\nlet b = vec![69, 88, 65, 77, 80, 76, 69, 33];\nlet mut buf = Reader::new(b.as_slice());\n\nmatch Data::read::\u003cBigEndian\u003e(\u0026mut buf) {\n    Ok(data) =\u003e assert_eq!(data.inner, 17752),\n    Err(err) =\u003e panic!(\"{}\", err)\n}\n```\n\nCustomize the derive macro by annotating the struct with additional attributes: `#[binbuf()]`. Currently, the following\ncontainer attributes are supported:\n\n- `#[binbuf(error = \"...\")]`\n\n  \u003e Default value: `binbuf::error::BufferError`\n\n  Provide a custom error. The error has to implement these traits:\n\n  - `std::fmt::Display`\n  - `std::error::Error`\n  - `From\u003cBufferError\u003e`\n\n- `#[binbuf(endianness = \"...\")]`\n\n  \u003e Default value: `both`\n\n  Specify the supported endianness for the `ReadableVerify` trait. Possible values are:\n\n  - `little`\n  - `both`\n  - `big`\n\nEnums can be tagged with one additional attribute:\n\n- `#[binbuf(repr = \"...\")]`\n\n  \u003e Default value: `u8`\n\nThe library works well with the `thiserror` crate. Implementing custom errors with the `Error` derive macro is\nstraightforward:\n\n```rust\nuse thiserror::Error;\n\n#[derive(Error)]\nenum CustomError {\n    #[error(\"Invalid data\")]\n    Invalid,\n\n    #[error(\"Buffer error: {0}\")]\n    BufferError(#[from] BufferError)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechassi%2Fbinbuf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechassi%2Fbinbuf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechassi%2Fbinbuf/lists"}