Struct BinaryUsage

Source
pub struct BinaryUsage;
👎Deprecated
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

Source

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

Source

pub fn assert_binary_string(bin: String) -> bool

Asserts the Input Is A Binary String, or a String with only:

  • 0
  • 1
  • No Whitespace
Source

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

Source

pub fn assert_bytes(bin: String) -> bool

Asserts The Input Has (8 * n) bits or contains full bytes using the remainder function

Source

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

Source

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

Source

pub fn add_spaces(bin: String) -> Result<String, ()>

Source

pub fn remove_spaces(bin: String) -> String

Removes All Whitespace From String And Returns String

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.