[−][src]Trait tari_utilities::byte_array::ByteArray
Many of the types in this crate are just large numbers (256 bit usually). This trait provides the common functionality for types like secret keys, signatures, commitments etc. to be converted to and from byte arrays and hexadecimal formats.
Required methods
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.
fn as_bytes(&self) -> &[u8]
Return the type as a byte array
Provided methods
fn to_vec(&self) -> Vec<u8>
Return the type as a byte vector
fn from_vec(v: &Vec<u8>) -> Result<Self, ByteArrayError>
Try and convert the given byte vector to the implemented type. Any failures (incorrect string length etc) return a KeyError with an explanatory note.