Trait ToByteArray

Source
pub trait ToByteArray {
    const NUM_FIELDS: usize;
    const IS_PRIMITIVE: bool = false;

    // Required method
    fn to_byte_array(&self) -> Result<[u8; 32], HasherError>;
}

Required Associated Constants§

Provided Associated Constants§

Source

const IS_PRIMITIVE: bool = false

Required Methods§

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§

Source§

impl ToByteArray for bool

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Big endian representation of bool.

Source§

const NUM_FIELDS: usize = 1usize

Source§

const IS_PRIMITIVE: bool = true

Source§

impl ToByteArray for i8

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Big endian representation of $int_ty.

Source§

const IS_PRIMITIVE: bool = true

Source§

const NUM_FIELDS: usize = 1usize

Source§

impl ToByteArray for i16

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Big endian representation of $int_ty.

Source§

const IS_PRIMITIVE: bool = true

Source§

const NUM_FIELDS: usize = 1usize

Source§

impl ToByteArray for i32

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Big endian representation of $int_ty.

Source§

const IS_PRIMITIVE: bool = true

Source§

const NUM_FIELDS: usize = 1usize

Source§

impl ToByteArray for i64

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Big endian representation of $int_ty.

Source§

const IS_PRIMITIVE: bool = true

Source§

const NUM_FIELDS: usize = 1usize

Source§

impl ToByteArray for i128

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Big endian representation of $int_ty.

Source§

const IS_PRIMITIVE: bool = true

Source§

const NUM_FIELDS: usize = 1usize

Source§

impl ToByteArray for u8

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Big endian representation of $int_ty.

Source§

const IS_PRIMITIVE: bool = true

Source§

const NUM_FIELDS: usize = 1usize

Source§

impl ToByteArray for u16

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Big endian representation of $int_ty.

Source§

const IS_PRIMITIVE: bool = true

Source§

const NUM_FIELDS: usize = 1usize

Source§

impl ToByteArray for u32

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Big endian representation of $int_ty.

Source§

const IS_PRIMITIVE: bool = true

Source§

const NUM_FIELDS: usize = 1usize

Source§

impl ToByteArray for u64

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Big endian representation of $int_ty.

Source§

const IS_PRIMITIVE: bool = true

Source§

const NUM_FIELDS: usize = 1usize

Source§

impl ToByteArray for u128

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Big endian representation of $int_ty.

Source§

const IS_PRIMITIVE: bool = true

Source§

const NUM_FIELDS: usize = 1usize

Source§

impl ToByteArray for String

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Max allowed String length is 31 bytes. For longer strings hash to field size or provide a custom implementation.

Source§

const NUM_FIELDS: usize = 1usize

Source§

impl ToByteArray for [u8; 1]

Source§

impl ToByteArray for [u8; 2]

Source§

impl ToByteArray for [u8; 4]

Source§

impl ToByteArray for [u8; 5]

Source§

impl ToByteArray for [u8; 6]

Source§

impl ToByteArray for [u8; 7]

Source§

impl ToByteArray for [u8; 8]

Source§

impl ToByteArray for [u8; 9]

Source§

impl ToByteArray for [u8; 10]

Source§

impl ToByteArray for [u8; 11]

Source§

impl ToByteArray for [u8; 12]

Source§

impl ToByteArray for [u8; 13]

Source§

impl ToByteArray for [u8; 14]

Source§

impl ToByteArray for [u8; 15]

Source§

impl ToByteArray for [u8; 16]

Source§

impl ToByteArray for [u8; 17]

Source§

impl ToByteArray for [u8; 18]

Source§

impl ToByteArray for [u8; 19]

Source§

impl ToByteArray for [u8; 20]

Source§

impl ToByteArray for [u8; 21]

Source§

impl ToByteArray for [u8; 22]

Source§

impl ToByteArray for [u8; 23]

Source§

impl ToByteArray for [u8; 24]

Source§

impl ToByteArray for [u8; 25]

Source§

impl ToByteArray for [u8; 26]

Source§

impl ToByteArray for [u8; 27]

Source§

impl ToByteArray for [u8; 28]

Source§

impl ToByteArray for [u8; 29]

Source§

impl ToByteArray for [u8; 30]

Source§

impl ToByteArray for [u8; 31]

Source§

impl<T: ToByteArray> ToByteArray for Option<T>

Source§

fn to_byte_array(&self) -> Result<[u8; 32], HasherError>

Some(PrimitiveType) prefixed with 1 byte Some(T) -> Poseidon::hash(T::to_byte_array()) None -> [0u8;32]

Source§

const NUM_FIELDS: usize = 1usize

Implementors§