Trait tari_utilities::byte_array::ByteArray
source · pub trait ByteArray: Sized {
// Required methods
fn from_bytes(bytes: &[u8]) -> Result<Self, ByteArrayError>;
fn as_bytes(&self) -> &[u8] ⓘ;
// Provided methods
fn to_vec(&self) -> Vec<u8> { ... }
fn from_vec(v: &Vec<u8>) -> Result<Self, ByteArrayError> { ... }
}
Required Methods§
sourcefn from_bytes(bytes: &[u8]) -> Result<Self, ByteArrayError>
fn from_bytes(bytes: &[u8]) -> Result<Self, ByteArrayError>
Try and convert the given byte array to the implemented type. Any failures (incorrect array length, implementation-specific checks, etc.) return a ByteArrayError with an explanatory note.
Provided Methods§
sourcefn from_vec(v: &Vec<u8>) -> Result<Self, ByteArrayError>
fn from_vec(v: &Vec<u8>) -> Result<Self, ByteArrayError>
Try and convert the given byte vector to the implemented type.
Errors
Any failures (incorrect string length, etc) return an ByteArrayError with an explanatory note.