Trait sp_core::crypto::ByteArray

source ·
pub trait ByteArray: AsRef<[u8]> + AsMut<[u8]> + for<'a> TryFrom<&'a [u8], Error = ()> {
    const LEN: usize;

    // Provided methods
    fn from_slice(data: &[u8]) -> Result<Self, ()> { ... }
    fn to_raw_vec(&self) -> Vec<u8>  { ... }
    fn as_slice(&self) -> &[u8]  { ... }
}
Expand description

Trait used for types that are really just a fixed-length array.

Required Associated Constants§

source

const LEN: usize

The “length” of the values of this type, which is always the same.

Provided Methods§

source

fn from_slice(data: &[u8]) -> Result<Self, ()>

A new instance from the given slice that should be Self::LEN bytes long.

source

fn to_raw_vec(&self) -> Vec<u8>

Return a Vec<u8> filled with raw data.

source

fn as_slice(&self) -> &[u8]

Return a slice filled with raw data.

Implementors§

source§

impl ByteArray for sp_core::bandersnatch::Public

source§

const LEN: usize = 33usize

source§

impl ByteArray for Signature

source§

const LEN: usize = 65usize

source§

impl ByteArray for sp_core::ecdsa::Public

source§

const LEN: usize = 33usize

source§

impl ByteArray for sp_core::ed25519::Public

source§

const LEN: usize = 32usize

source§

impl ByteArray for sp_core::sr25519::Public

source§

const LEN: usize = 32usize

source§

impl ByteArray for AccountId32

source§

const LEN: usize = 32usize

source§

impl ByteArray for Dummy

source§

const LEN: usize = 0usize

source§

impl<T> ByteArray for sp_core::bls::Public<T>

source§

const LEN: usize = 144usize