[][src]Trait tari_utilities::byte_array::ByteArray

pub trait ByteArray: Sized {
    fn from_bytes(bytes: &[u8]) -> Result<Self, ByteArrayError>;
fn as_bytes(&self) -> &[u8]; fn to_vec(&self) -> Vec<u8> { ... }
fn from_vec(v: &Vec<u8>) -> Result<Self, ByteArrayError> { ... } }

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

Loading content...

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.

Loading content...

Implementations on Foreign Types

impl ByteArray for Vec<u8>[src]

impl ByteArray for [u8; 32][src]

Loading content...

Implementors

Loading content...