pub struct BinaryUsage;
Expand description
§Binary Usage
The BinaryUsage
Struct is used to perform functions or actions on Binary Strings
, such as:
- Adding/Removing Whitespace
- Asserting Binary Strings
- Asserting Binary Whitespace Strings
- Asserting Bytes
- Counting Bits
- Counting Bytes
Implementations§
Source§impl BinaryUsage
impl BinaryUsage
Sourcepub fn assert_binary(bin: String) -> bool
pub fn assert_binary(bin: String) -> bool
Asserts The Input Is A Binary String
, or a string with only:
0
1
This function is the same as assert_binary_string()
just with a different name
Sourcepub fn assert_binary_string(bin: String) -> bool
pub fn assert_binary_string(bin: String) -> bool
Asserts the Input Is A Binary String
, or a String with only:
0
1
- No Whitespace
Sourcepub fn assert_binary_whitespace(bin: String) -> bool
pub fn assert_binary_whitespace(bin: String) -> bool
Asserts The Input Is A Binary Whitespace String
, or a String with only:
0
1
whitespace
TODO: Add a check for whitespace to be every 9nth character
Sourcepub fn assert_bytes(bin: String) -> bool
pub fn assert_bytes(bin: String) -> bool
Asserts The Input Has (8
* n
) bits or contains full bytes using the remainder function
Sourcepub fn count_bits(bin: String) -> Result<usize, ()>
pub fn count_bits(bin: String) -> Result<usize, ()>
Count number of bits for both a “Binary String” and “Binary Whitespace String” and returns a Result of either a usize
or on error, empty response
Sourcepub fn count_bytes(bin: String) -> Result<usize, ()>
pub fn count_bytes(bin: String) -> Result<usize, ()>
Count number of bytes for both a “Binary String” and “Binary Whitespace String” and returns a Result of either a usize
or on error, empty response
pub fn add_spaces(bin: String) -> Result<String, ()>
Sourcepub fn remove_spaces(bin: String) -> String
pub fn remove_spaces(bin: String) -> String
Removes All Whitespace From String And Returns String