Trait BytesRepresentable

pub trait BytesRepresentable<E = GeneralError>: AsRef<[u8]> + for<'a> TryFrom<&'a [u8], Error = E> {
    const SIZE: usize;

    // Provided method
    fn into_boxed(self) -> Box<[u8]> { ... }
}
Expand description

Represents a type that is already internally represented by a fixed size byte array, and therefore requires no memory allocation to represent the type in binary encoding.

This is a strict subset of BytesEncodable, see its documentation for details.

Required Associated Constants§

const SIZE: usize

Size of the encoded byte array.

Provided Methods§

fn into_boxed(self) -> Box<[u8]>

Convenience function to copy this type’s binary representation into a Box.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl BytesRepresentable for Challenge

§

const SIZE: usize = 33usize

§

impl BytesRepresentable for CompressedPublicKey

§

const SIZE: usize = 33usize

§

impl BytesRepresentable for CurvePoint

§

const SIZE: usize = 33usize

§

impl BytesRepresentable for HalfKey

§

const SIZE: usize = 32usize

Size of the secp256k1 secret scalar representing the half key.

§

impl BytesRepresentable for Hash

§

const SIZE: usize = 32usize

Size of the digest is 32 bytes.

§

impl BytesRepresentable for HoprSenderId

§

const SIZE: usize = 18usize

§

impl BytesRepresentable for OffchainPublicKey

§

const SIZE: usize = 32usize

Size of the public key (compressed Edwards Y coordinate)

§

impl BytesRepresentable for OffchainSignature

§

const SIZE: usize = 64usize

Size of the EdDSA signature using Ed25519.

§

impl BytesRepresentable for Response

§

const SIZE: usize = 32usize

Fixed size of the PoR challenge response.

§

impl BytesRepresentable for Signature

§

const SIZE: usize = 64usize

§

impl BytesRepresentable for SimplePseudonym

§

const SIZE: usize = 10usize

§

impl<S, H, const P: usize> BytesRepresentable for MetaPacket<S, H, P>
where S: SphinxSuite, H: SphinxHeaderSpec,

§

const SIZE: usize

§

impl<const N: usize> BytesRepresentable<TryFromSliceError> for [u8; N]

§

const SIZE: usize = N

Implementors§