UninitByteArray

Struct UninitByteArray 

Source
pub struct UninitByteArray { /* private fields */ }
Expand description

marker struct for uninitialized byte arrays that still require padding information for odd arrays from user. If you wish for a default constructor please check ByteArray::default. Please note that this struct represents an intermediate state and is not to be used by the client directly

Implementations§

Source§

impl UninitByteArray

Source

pub fn with_capacity(self, byte_size: usize) -> Self

pre initializes the capacity for more efficient pre-allocation this returns an Uninitialized Byte Array and is used in cases where the user wants to override the padding direction with UninitByteArray::with_odd_pad_dir

§Note

in cases where the Default odd array padding is sufficient and more efficient please use ByteArray::with_capacity instead

§Example
use byte_array_ops::byte_array::model::{ByteArray, ByteArrayOddWordPad};

let arr = ByteArray::new_uninit()
        .with_capacity(20)
        .with_odd_pad_dir(ByteArrayOddWordPad::LeftPadding)
        .with_hex("efab123").expect("failed to convert hex");

// In cases where the default padding is sufficient please use the direct constructor instead
let arr_2 = ByteArray::with_capacity(20)
        .with_hex("efab123").expect("failed to convert");

assert_eq!(arr,arr_2);
assert_eq!(arr_2.as_bytes(),[0x0e,0xfa,0xb1,0x23]);
Source

pub fn with_odd_pad_dir(self, pad_dir: ByteArrayOddWordPad) -> ByteArray

Explicitly sets the padding direction. This is not needed in general and is only provided in cases where padding must be explicitly set for readability purposes. By default, ByteArray uses Left Padding

§Warning

Please read documentation of ByteArrayOddWordPad for an understanding of what padding means in this context

§Example
use byte_array_ops::byte_array::model::{ByteArray, ByteArrayOddWordPad};
let arr = ByteArray::new_uninit()
        .with_odd_pad_dir(ByteArrayOddWordPad::LeftPadding)
        .with_hex("feab123").expect("failed to convert");

assert_eq!(arr.as_bytes(),[0x0f,0xea,0xb1,0x23]);

Trait Implementations§

Source§

impl Default for UninitByteArray

Source§

fn default() -> UninitByteArray

Returns the “default value” for a type. Read more

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.