{"id":16170194,"url":"https://github.com/porglezomp/bitmatch","last_synced_at":"2025-09-09T08:45:06.185Z","repository":{"id":57514554,"uuid":"234982281","full_name":"porglezomp/bitmatch","owner":"porglezomp","description":"A Rust crate that allows you to match, bind, and pack the individual bits of integers.","archived":false,"fork":false,"pushed_at":"2020-04-20T21:06:51.000Z","size":42,"stargazers_count":115,"open_issues_count":2,"forks_count":5,"subscribers_count":8,"default_branch":"develop","last_synced_at":"2025-03-31T16:16:16.294Z","etag":null,"topics":["binary","bitpacking","decoding","encoding","no-std","rust","rust-library"],"latest_commit_sha":null,"homepage":"https://docs.rs/bitmatch","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/porglezomp.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":"2020-01-19T23:16:13.000Z","updated_at":"2025-02-09T12:58:43.000Z","dependencies_parsed_at":"2022-09-06T04:00:23.456Z","dependency_job_id":null,"html_url":"https://github.com/porglezomp/bitmatch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porglezomp%2Fbitmatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porglezomp%2Fbitmatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porglezomp%2Fbitmatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porglezomp%2Fbitmatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/porglezomp","download_url":"https://codeload.github.com/porglezomp/bitmatch/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247704571,"owners_count":20982298,"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","bitpacking","decoding","encoding","no-std","rust","rust-library"],"created_at":"2024-10-10T03:17:49.104Z","updated_at":"2025-04-07T18:15:19.935Z","avatar_url":"https://github.com/porglezomp.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bitmatch\n\n[![Crates.io Library Version Number](https://img.shields.io/crates/v/bitmatch)](https://crates.io/crates/bitmatch)\n[![Crates.io Library License](https://img.shields.io/crates/l/bitmatch)](https://www.mozilla.org/en-US/MPL/2.0/)\n[![Docs.rs Documentation Version Number](https://docs.rs/bitmatch/badge.svg)](https://docs.rs/bitmatch/)\n\nThe bitmatch crate provides tools for packing and unpacking integers as\nsequences of bits. Supports `#![no_std]`.\n\n## Examples\n\nUsing `#[bitmatch]` with a `let` unpacks the bits into separate\nsingle-character variables for each letter you use.\n\nUsing `bitpack!()` re-packs the bits from those single-character variables\ninto a single integer.\n\n```rust\nuse bitmatch::bitmatch;\n\n#[bitmatch]\nfn interleave(n: u8) -\u003e u8 {\n    #[bitmatch]\n    let \"xxxx_yyyy\" = n;\n    bitpack!(\"xyxy_xyxy\")\n}\n\nfn main() {\n    assert_eq!(interleave(0xF0), 0xAA);\n}\n```\n\nYou can use `#[bitmatch]` on a `match` as well, and it will ensure that the\nliteral portions match, and bind the variable portions.\n\n```rust\nuse bitmatch::bitmatch;\n#[bitmatch]\nfn decode(inst: u8) -\u003e String {\n    #[bitmatch]\n    match inst {\n        \"00oo_aabb\" =\u003e format!(\"Op {}, {}, {}\", o, a, b),\n        \"0100_aaii\" =\u003e format!(\"Val {}, {}\", a, i),\n        \"01??_????\" =\u003e format!(\"Invalid\"),\n        \"10ii_aabb\" =\u003e format!(\"Ld {}, {}, {}\", a, b, i),\n        \"11ii_aabb\" =\u003e format!(\"St {}, {}, {}\", a, b, i),\n    }\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fporglezomp%2Fbitmatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fporglezomp%2Fbitmatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fporglezomp%2Fbitmatch/lists"}