{"id":50429057,"url":"https://github.com/oxidecomputer/byte-wrapper","last_synced_at":"2026-05-31T12:31:00.846Z","repository":{"id":103491088,"uuid":"602856790","full_name":"oxidecomputer/byte-wrapper","owner":"oxidecomputer","description":"Serialize [u8; N] as bytes or as human-readable strings, depending on the format.","archived":false,"fork":false,"pushed_at":"2026-03-05T03:55:54.000Z","size":4722,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":20,"default_branch":"main","last_synced_at":"2026-03-05T06:13:15.325Z","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/oxidecomputer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2023-02-17T04:40:34.000Z","updated_at":"2026-03-05T03:55:57.000Z","dependencies_parsed_at":"2025-07-22T23:38:57.521Z","dependency_job_id":"c559d818-7a64-4446-99fe-9c39624a257e","html_url":"https://github.com/oxidecomputer/byte-wrapper","commit_stats":null,"previous_names":["oxidecomputer/serde_bytefmt"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/oxidecomputer/byte-wrapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fbyte-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fbyte-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fbyte-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fbyte-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxidecomputer","download_url":"https://codeload.github.com/oxidecomputer/byte-wrapper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fbyte-wrapper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33731998,"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-05-31T02:00:06.040Z","response_time":95,"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":[],"created_at":"2026-05-31T12:31:00.758Z","updated_at":"2026-05-31T12:31:00.845Z","avatar_url":"https://github.com/oxidecomputer.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- cargo-sync-rdme title [[ --\u003e\n# byte-wrapper\n\u003c!-- cargo-sync-rdme ]] --\u003e\n\n\u003c!-- cargo-sync-rdme badge [[ --\u003e\n![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/byte-wrapper.svg?)\n[![crates.io](https://img.shields.io/crates/v/byte-wrapper.svg?logo=rust)](https://crates.io/crates/byte-wrapper)\n[![docs.rs](https://img.shields.io/docsrs/byte-wrapper.svg?logo=docs.rs)](https://docs.rs/byte-wrapper)\n[![Rust: ^1.88.0](https://img.shields.io/badge/rust-^1.88.0-93450a.svg?logo=rust)](https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field)\n\u003c!-- cargo-sync-rdme ]] --\u003e\n\n\u003c!-- cargo-sync-rdme rustdoc [[ --\u003e\nNewtype wrappers for byte arrays and vectors with hex and base64\nformatting.\n\nThis crate provides wrapper types that display byte data in\nhuman-readable encodings. [`HexArray\u003cN\u003e`](https://docs.rs/byte-wrapper/0.1.0/byte_wrapper/hex_array/struct.HexArray.html) encodes fixed-length byte\narrays as hex strings, and [`Base64Vec`](https://docs.rs/byte-wrapper/0.1.0/byte_wrapper/base64_vec/struct.Base64Vec.html) encodes variable-length\nbyte vectors as base64 strings.\n\nWith the `serde` feature, both types implement `Serialize` and\n`Deserialize`, encoding as human-readable strings (hex or base64) in text\nformats like JSON, and as efficient raw bytes in binary formats like [CBOR].\nYou do not have to use the newtypes in your own type definitions; you can\nrefer to them via `#[serde(with = \"...\")]` instead.\n\nWith the `schemars08` feature, both types implement [`JsonSchema`],\nincluding automatic opt-in replacement with\n[typify](https://crates.io/crates/typify) and\n[progenitor](https://crates.io/crates/progenitor).\n\n## Types\n\n* [`HexArray\u003cN\u003e`](https://docs.rs/byte-wrapper/0.1.0/byte_wrapper/hex_array/struct.HexArray.html) encodes a fixed-length byte array as a hex\n  string. (Requires the `hex` feature.)\n* [`Base64Vec`](https://docs.rs/byte-wrapper/0.1.0/byte_wrapper/base64_vec/struct.Base64Vec.html) encodes a variable-length byte vector as a base64\n  string. (Requires the `base64` feature.)\n\n## Examples\n\n````rust\nuse byte_wrapper::HexArray;\n\nlet h = HexArray::new([0x01, 0x02, 0xab, 0xff]);\nassert_eq!(h.to_string(), \"0102abff\");\n\nlet parsed: HexArray\u003c4\u003e = \"0102abff\".parse().unwrap();\nassert_eq!(parsed, h);\n````\n\nWith the **`serde`** feature:\n\n````rust\nuse byte_wrapper::HexArray;\nuse serde::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize)]\nstruct Record {\n    checksum: HexArray\u003c32\u003e,\n}\n````\n\nUsing `#[serde(with = \"...\")]` on an existing byte array:\n\n````rust\nuse byte_wrapper::HexArray;\nuse serde::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize)]\nstruct Record {\n    #[serde(with = \"HexArray::\u003c32\u003e\")]\n    checksum: [u8; 32],\n}\n````\n\n## Alternatives\n\nSeveral crates solve parts of this problem, often using slightly\ndifferent approaches from `byte-wrapper`.\n\n|feature|`byte-wrapper`|[`serde-human-bytes`] 0.1.2|[`serde-encoded-bytes`] 0.2.1|[`serde_with`] 3.17.0|[`hex-buffer-serde`] 0.4.0|[`hexutil`] 0.1.0|[`serde-bytes-repr`] 0.3.0|\n|-------|--------------|-------------------------|---------------------------|-------------------|------------------------|---------------|------------------------|\n|newtype wrappers|yes|yes (hex only)|no|no|no|no|no|\n|[`is_human_readable()`] switch|yes|yes|yes|no|yes|yes|no|\n|[`Display`] / [`FromStr`] / [`Deref`]|yes|[`Deref`] only|no|no|no|[`Display`] / [`FromStr`] via macro|no|\n|hex encoding|yes|yes|yes|yes|yes|yes|yes|\n|base64 encoding|yes|yes|yes|yes|no|no|yes|\n|`[u8; N]` support|yes|yes|yes|yes|yes|via macros|no|\n|`no_std`|yes|yes|yes|yes|yes|yes|no|\n|[`JsonSchema`] (schemars)|yes|no|no|yes|no|no|no|\n|`#[serde(with)]` support|yes|yes|yes|yes|yes|no|no|\n\nThe closest alternatives are:\n\n* [`serde-human-bytes`], which provides\n  newtypes with [`Deref`], [`is_human_readable()`] switching,\n  and both hex and base64 encoding, but lacks [`Display`] /\n  [`FromStr`] and [`JsonSchema`] support.\n\n* [`serde-encoded-bytes`], which provides most of the features of this\n  crate, and is more general in some ways, but doesn’t provide newtype\n  or schemars support.\n\n* [`serde_with`], which offers schemars integration but does not check\n  [`is_human_readable()`] by default.\n\n## Features\n\n* **`hex`**: enables [`HexArray`](https://docs.rs/byte-wrapper/0.1.0/byte_wrapper/hex_array/struct.HexArray.html). *Enabled by default.*\n* **`base64`**: enables [`Base64Vec`](https://docs.rs/byte-wrapper/0.1.0/byte_wrapper/base64_vec/struct.Base64Vec.html) (implies `alloc`).\n  *Enabled by default.*\n* **`alloc`**: enables `alloc` support (required by `base64`).\n* **`serde`**: implements `Serialize` and `Deserialize` for\n  enabled types. *Not enabled by default.*\n* **`schemars08`**: derives `JsonSchema` for enabled types.\n  *Not enabled by default.*\n\n[CBOR]: https://cbor.io/\n[`JsonSchema`]: https://docs.rs/schemars/0.8/schemars/trait.JsonSchema.html\n[`serde-human-bytes`]: https://docs.rs/serde-human-bytes\n[`serde-encoded-bytes`]: https://docs.rs/serde-encoded-bytes\n[`serde_with`]: https://docs.rs/serde_with\n[`hex-buffer-serde`]: https://docs.rs/hex-buffer-serde\n[`hexutil`]: https://docs.rs/hexutil\n[`serde-bytes-repr`]: https://docs.rs/serde-bytes-repr\n[`is_human_readable()`]: https://docs.rs/serde/latest/serde/trait.Serializer.html#method.is_human_readable\n[`Display`]: https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html\n[`FromStr`]: https://doc.rust-lang.org/nightly/core/str/traits/trait.FromStr.html\n[`Deref`]: https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html\n\u003c!-- cargo-sync-rdme ]] --\u003e\n\n## License\n\nLicensed under either of [Apache License, Version 2.0](LICENSE-APACHE)\nor [MIT license](LICENSE-MIT) at your option.\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in this crate by you, as defined in the\nApache-2.0 license, shall be dual licensed as above, without any\nadditional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxidecomputer%2Fbyte-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxidecomputer%2Fbyte-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxidecomputer%2Fbyte-wrapper/lists"}