{"id":19513557,"url":"https://github.com/atropinetears/to-binary","last_synced_at":"2026-06-15T17:31:42.525Z","repository":{"id":57670002,"uuid":"264779245","full_name":"AtropineTears/To-Binary","owner":"AtropineTears","description":"A Rust Library For Conversion To Binary String","archived":false,"fork":false,"pushed_at":"2021-01-11T04:19:36.000Z","size":25,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-23T16:41:45.755Z","etag":null,"topics":["bin","binary","binary-converter","binary-strings","conversion","hexadecimal","library","rust","rust-crate","rust-lang"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/to-binary","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/AtropineTears.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-05-17T23:54:47.000Z","updated_at":"2024-01-10T16:53:43.000Z","dependencies_parsed_at":"2022-09-26T20:40:42.771Z","dependency_job_id":null,"html_url":"https://github.com/AtropineTears/To-Binary","commit_stats":null,"previous_names":["0xatropine/to-binary"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtropineTears%2FTo-Binary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtropineTears%2FTo-Binary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtropineTears%2FTo-Binary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtropineTears%2FTo-Binary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AtropineTears","download_url":"https://codeload.github.com/AtropineTears/To-Binary/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240762504,"owners_count":19853495,"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":["bin","binary","binary-converter","binary-strings","conversion","hexadecimal","library","rust","rust-crate","rust-lang"],"created_at":"2024-11-10T23:30:51.323Z","updated_at":"2025-12-12T13:07:26.996Z","avatar_url":"https://github.com/AtropineTears.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# To-Binary: A Rust Crate For Conversion To A `BinaryString`\n[![Crates.io](https://img.shields.io/crates/v/to-binary?style=flat-square)](https://crates.io/crates/to-binary)\n![Crates.io](https://img.shields.io/crates/l/to-binary?style=flat-square)\n[![Build Status](https://travis-ci.org/0xAtropine/To-Binary.svg?branch=master)](https://travis-ci.org/0xAtropine/To-Binary)\n\nA Rust Library For Conversion To new type `BinaryString`. `BinaryString` is a singled-fielded, tuple struct that holds a **BinaryString** or **BinaryWhitespaceString** and is of the type `String`.\n\nIt allows: \n\n* Asserting Whether a Given Input Is a Binary String\n* Asserting Number of Bits/Bytes\n* Counting of Bits and Bytes\n* Adding/Removing Whitespace Between Bytes\n\n## How To Use\n\nRead **Examples** and **Read The Documentation**\n\n### Conversion To `BinaryString`\n\nThese examples show how you can convert from one type to the `BinaryString` type.\n\n```rust\nuse to_binary::{BinaryString,BinaryError};\n\nfn main(){\n    // Hexadecimal\n    let hex = BinaryString::from_hex(\"2879E653864EA6047FEBBBD9AE6DA8DA\").unwrap();\n    \n    // String\n    let x = BinaryString::from(String::from(\"Test\"));\n    assert_eq!(bin_string_2,\"01010100011001010111001101110100\")\n  \n  \t// str\n  \tlet y = BinaryString::from(\"Hello World\");\n  \n  \t// Byte\n  \tlet byte = BinaryString::from(118u8);\n  \t\n  \t// Vector\n  \tlet vector = vec![36,57,123,38,2];\n  \tlet bin_vector = BinaryString::from(vector);\n}\n```\n\n### Adding or Removing Whitespace From A `BinaryString`\n\nThis example shows how you can add whitespace between bytes or remove whitespace from a `BinaryString`\n\n```rust\nuse to_binary::{BinaryString,BinaryError};\n\nfn test_whitespace() {\n        // Conversion To `BinaryString` Struct From Hex\n        let x: BinaryString = BinaryString::from_hex(\"FF8628AA\").unwrap();\n\n        // Creates New Struct With Spaces\n        let with_spaces: BinaryString = x.add_spaces().unwrap();\n\n        // Removes Spaces And Creates New Struct\n        let removed_spaces: BinaryString = with_spaces.remove_spaces();\n\n        // Prints Out Information\n        println!(\"x: {}\", x);\n        println!(\"with_spaces : {}\", with_spaces);\n        println!(\"removed spaces: {}\", removed_spaces);\n\n        let is_true: bool = with_spaces.assert_binary_whitespace();\n\n        // Asserts It Works And The Answer Without Spaces Is Same As Initial\n        assert_eq!(is_true, true);\n        assert_eq!(x, removed_spaces);\n}\n```\n\n### Using Binary Methods On `BinaryString`\n\nThere are many `BinaryString` Methods That Can Be Used. This is a few of them that may be useful.\n\n```rust\nfn main(){\n  \t// Conversion To `BinaryString` Struct From Hex\n  \tlet x: BinaryString = BinaryString::from_hex(\"FF8628AA\").unwrap();\n  \n  \t// Checks Whether The Input Is Binary\n    let check_if_binary: bool = x.assert_binary();\n\n    // Assert Input Is Binary\n    assert_eq!(check_if_binary, true);\n\n    // Retrieve Sizes Of Binary Input (Bits and Bytes)\n    let size_in_bits = x.bits().unwrap();\n    let size_in_bytes = x.bytes().unwrap();\n\n    // Verifies Sizes Of Binary Inputs\n    let verify_bit_length: bool = x.assert_bit_length(size_in_bits);\n    let verify_byte_length: bool = x.assert_byte_length(size_in_bytes);\n\n    // Assert Sizes Are Correct\n    assert_eq!(verify_bit_length, true);\n    assert_eq!(verify_byte_length, true);\n}\n```\n\n## License\n\nLicensed under either of\n\n* Apache License, Version 2.0\n\n* MIT license\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatropinetears%2Fto-binary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatropinetears%2Fto-binary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatropinetears%2Fto-binary/lists"}