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§
const NUM_FIELDS: usize
Provided Associated Constants§
const IS_PRIMITIVE: bool = false
Required Methods§
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
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
impl ToByteArray for bool
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Big endian representation of bool.
const NUM_FIELDS: usize = 1usize
const IS_PRIMITIVE: bool = true
Source§impl ToByteArray for i8
impl ToByteArray for i8
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Big endian representation of $int_ty.
const IS_PRIMITIVE: bool = true
const NUM_FIELDS: usize = 1usize
Source§impl ToByteArray for i16
impl ToByteArray for i16
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Big endian representation of $int_ty.
const IS_PRIMITIVE: bool = true
const NUM_FIELDS: usize = 1usize
Source§impl ToByteArray for i32
impl ToByteArray for i32
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Big endian representation of $int_ty.
const IS_PRIMITIVE: bool = true
const NUM_FIELDS: usize = 1usize
Source§impl ToByteArray for i64
impl ToByteArray for i64
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Big endian representation of $int_ty.
const IS_PRIMITIVE: bool = true
const NUM_FIELDS: usize = 1usize
Source§impl ToByteArray for i128
impl ToByteArray for i128
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Big endian representation of $int_ty.
const IS_PRIMITIVE: bool = true
const NUM_FIELDS: usize = 1usize
Source§impl ToByteArray for u8
impl ToByteArray for u8
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Big endian representation of $int_ty.
const IS_PRIMITIVE: bool = true
const NUM_FIELDS: usize = 1usize
Source§impl ToByteArray for u16
impl ToByteArray for u16
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Big endian representation of $int_ty.
const IS_PRIMITIVE: bool = true
const NUM_FIELDS: usize = 1usize
Source§impl ToByteArray for u32
impl ToByteArray for u32
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Big endian representation of $int_ty.
const IS_PRIMITIVE: bool = true
const NUM_FIELDS: usize = 1usize
Source§impl ToByteArray for u64
impl ToByteArray for u64
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Big endian representation of $int_ty.
const IS_PRIMITIVE: bool = true
const NUM_FIELDS: usize = 1usize
Source§impl ToByteArray for u128
impl ToByteArray for u128
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Big endian representation of $int_ty.
const IS_PRIMITIVE: bool = true
const NUM_FIELDS: usize = 1usize
Source§impl ToByteArray for String
impl ToByteArray for String
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
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.
const NUM_FIELDS: usize = 1usize
Source§impl ToByteArray for [u8; 1]
impl ToByteArray for [u8; 1]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 2]
impl ToByteArray for [u8; 2]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 4]
impl ToByteArray for [u8; 4]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 5]
impl ToByteArray for [u8; 5]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 6]
impl ToByteArray for [u8; 6]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 7]
impl ToByteArray for [u8; 7]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 8]
impl ToByteArray for [u8; 8]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 9]
impl ToByteArray for [u8; 9]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 10]
impl ToByteArray for [u8; 10]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 11]
impl ToByteArray for [u8; 11]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 12]
impl ToByteArray for [u8; 12]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 13]
impl ToByteArray for [u8; 13]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 14]
impl ToByteArray for [u8; 14]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 15]
impl ToByteArray for [u8; 15]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 16]
impl ToByteArray for [u8; 16]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 17]
impl ToByteArray for [u8; 17]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 18]
impl ToByteArray for [u8; 18]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 19]
impl ToByteArray for [u8; 19]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 20]
impl ToByteArray for [u8; 20]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 21]
impl ToByteArray for [u8; 21]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 22]
impl ToByteArray for [u8; 22]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 23]
impl ToByteArray for [u8; 23]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 24]
impl ToByteArray for [u8; 24]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 25]
impl ToByteArray for [u8; 25]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 26]
impl ToByteArray for [u8; 26]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 27]
impl ToByteArray for [u8; 27]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 28]
impl ToByteArray for [u8; 28]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 29]
impl ToByteArray for [u8; 29]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 30]
impl ToByteArray for [u8; 30]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl ToByteArray for [u8; 31]
impl ToByteArray for [u8; 31]
const NUM_FIELDS: usize = 1usize
fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
Source§impl<T: ToByteArray> ToByteArray for Option<T>
impl<T: ToByteArray> ToByteArray for Option<T>
Source§fn to_byte_array(&self) -> Result<[u8; 32], HasherError>
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]