[−][src]Struct to_binary::BinaryString
BinaryString (0bString + 0bWString)
This Struct is the Main Struct for Dealing with Binary Strings and Binary Whitespace Strings.
It is a Tuple Struct that only has a Single, Public Field which is a String and can be accessed with self.0.
How To Access The String Field
use to_binary::BinaryString; // Generate Binary String From &str let x = BinaryString::from("Hello"); // Access The Public "String" Field And Assign It To bin_string using field let bin_string: String = x.0; // Print Out Information println!("{}",bin_string);
Implementations
impl BinaryString[src]
pub fn from_hex<T: AsRef<[u8]>>(n: T) -> Result<BinaryString, FromHexError>[src]
Takes as input hexadecimal and outputs a Result containing a BinaryString and on Error, FromHexError
impl BinaryString[src]
pub fn assert_binary(&self) -> bool[src]
Asserts The Input Is A Binary String, or a string with only:
01
This function is the same as assert_binary_string() just with a different name
pub fn assert_binary_string(&self) -> bool[src]
Asserts the Input Is A Binary String, or a String with only:
01- No Whitespace
pub fn assert_binary_whitespace(&self) -> bool[src]
Asserts The Input Is A Binary Whitespace String, or a String with only:
01whitespace
TODO: Add a check for whitespace to be every 8th character
pub fn assert_bytes(&self) -> bool[src]
Asserts The Input Has (8 * n) bits or contains full bytes using the remainder function
This function calls the bits() method to retrieve the number of bits then does operation % 8 and compares it against 0
pub fn assert_bit_length(&self, len: usize) -> bool[src]
Asserts The Number of Bits In The String
The function bits() is called to compare to the parameter
pub fn assert_byte_length(&self, len: usize) -> bool[src]
Asserts The Number of Bytes In The String
The function bytes() is called to compare to the parameter
pub fn bits(&self) -> Result<usize, BinaryError>[src]
Count number of bits for both a "Binary String" and "Binary Whitespace String" and returns a Result of either a usize or a BinaryError
pub fn bytes(&self) -> Result<usize, BinaryError>[src]
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 remove_spaces(&self) -> BinaryString[src]
Removes All Whitespace From Binary String And Returns A BinaryString
pub fn add_spaces(&self) -> Result<BinaryString, BinaryError>[src]
Adds Whitespace Between Every Byte (8 bits)
Example Usage
// Imports use to_binary::{BinaryString,BinaryError}; // Generate `BinaryString` from &str "Test String" let x = BinaryString::from("Test String"); // Returns a `BinaryString` With Spaces Between Every Byte (8 bits) let bin_with_spaces = x.add_spaces().unwrap();
Trait Implementations
impl Clone for BinaryString[src]
fn clone(&self) -> BinaryString[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for BinaryString[src]
impl Default for BinaryString[src]
fn default() -> BinaryString[src]
impl Display for BinaryString[src]
impl<'_> From<&'_ [u8]> for BinaryString[src]
impl<'_> From<&'_ str> for BinaryString[src]
impl From<[u8; 32]> for BinaryString[src]
impl From<String> for BinaryString[src]
impl From<Vec<u8>> for BinaryString[src]
fn from(bytes: Vec<u8>) -> BinaryString[src]
impl From<u8> for BinaryString[src]
fn from(byte: u8) -> BinaryString[src]
impl Hash for BinaryString[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl PartialEq<BinaryString> for BinaryString[src]
fn eq(&self, other: &BinaryString) -> bool[src]
fn ne(&self, other: &BinaryString) -> bool[src]
impl PartialOrd<BinaryString> for BinaryString[src]
fn partial_cmp(&self, other: &BinaryString) -> Option<Ordering>[src]
fn lt(&self, other: &BinaryString) -> bool[src]
fn le(&self, other: &BinaryString) -> bool[src]
fn gt(&self, other: &BinaryString) -> bool[src]
fn ge(&self, other: &BinaryString) -> bool[src]
impl StructuralPartialEq for BinaryString[src]
Auto Trait Implementations
impl RefUnwindSafe for BinaryString
impl Send for BinaryString
impl Sync for BinaryString
impl Unpin for BinaryString
impl UnwindSafe for BinaryString
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,