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
impl UninitByteArray
Sourcepub fn with_capacity(self, byte_size: usize) -> Self
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]);Sourcepub fn with_odd_pad_dir(self, pad_dir: ByteArrayOddWordPad) -> ByteArray
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]);