[−][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> where
Self: Sized,
Self: Sized,
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_hex(&self) -> String
Return the hexadecimal string representation of the type
fn from_hex(hex: &str) -> Result<Self, ByteArrayError> where
Self: Sized,
Self: Sized,
Try and convert the given hexadecimal string to the type. Any failures (incorrect string length, non hex characters, etc) return a KeyError with an explanatory note.
fn to_vec(&self) -> Vec<u8>
Return the type as a byte vector
fn from_vec(v: &Vec<u8>) -> Result<Self, ByteArrayError> where
Self: Sized,
Self: Sized,
Try and convert the given byte vector to the implemented type. Any failures (incorrect string length etc) return a KeyError with an explanatory note.
Implementations on Foreign Types
impl ByteArray for Vec<u8>
[src]
fn to_hex(&self) -> String
[src]
fn from_hex(hex: &str) -> Result<Self, ByteArrayError> where
Self: Sized,
[src]
Self: Sized,
Try and convert the given hexadecimal string to the type. Any failures (incorrect string length, non hex characters, etc) return a KeyError with an explanatory note.
fn to_vec(&self) -> Vec<u8>
[src]
fn from_vec(v: &Vec<u8>) -> Result<Self, ByteArrayError> where
Self: Sized,
[src]
Self: Sized,
fn from_bytes(bytes: &[u8]) -> Result<Self, ByteArrayError> where
Self: Sized,
[src]
Self: Sized,
fn as_bytes(&self) -> &[u8]
[src]
impl ByteArray for [u8; 32]
[src]
fn from_bytes(bytes: &[u8]) -> Result<Self, ByteArrayError> where
Self: Sized,
[src]
Self: Sized,
fn as_bytes(&self) -> &[u8]
[src]
fn to_hex(&self) -> String
[src]
fn from_hex(hex: &str) -> Result<Self, ByteArrayError> where
Self: Sized,
[src]
Self: Sized,
fn to_vec(&self) -> Vec<u8>
[src]
fn from_vec(v: &Vec<u8>) -> Result<Self, ByteArrayError> where
Self: Sized,
[src]
Self: Sized,