aztec-nr - protocol_types::traits

Trait Packable

pub trait Packable {
    let N: u32;

    // Required methods
    pub fn pack(self) -> [Field; N];
    pub fn unpack(fields: [Field; N]) -> Self;
}

Trait for efficiently packing and unpacking Noir types into and from arrays of Fields.

The Packable trait allows types to be serialized and deserialized with a focus on minimizing the size of the resulting Field array. This trait is used when storage efficiency is critical (e.g. when storing data in the contract's public storage).

Associated Constants

Required methods

pub fn pack(self) -> [Field; N]

Packs the current value into a compact array of Field elements.

pub fn unpack(fields: [Field; N]) -> Self

Unpacks a compact array of Field elements into the original value.

Implementors

impl Packable for AddressNote

impl Packable for AztecAddress

impl<let M: u32, let N: u32> Packable for CompressedString<N, M>

impl Packable for ContractClassId

impl<let INITIAL_DELAY: u64, T> Packable for DelayedPublicMutableValues<T, INITIAL_DELAY>
where T: Packable

impl Packable for EmbeddedCurvePoint

impl Packable for Empty

impl Packable for EthAddress

impl Packable for Field

impl Packable for FieldCompressedString

impl<let N: u32, T> Packable for HasArrayWithGenerics<T, N>
where T: Packable

impl Packable for MockStruct

impl Packable for MockStruct

impl Packable for NoteMetadata

impl Packable for PartialUintNote

impl<Note> Packable for RetrievedNote<Note>
where Note: Packable

impl Packable for Smol

impl Packable for UintNote

impl Packable for ValueNote

impl<let M: u32, T> Packable for WithHash<T, M>
where T: Packable<N = M>

impl<let M: u32, T> Packable for [T; M]
where T: Packable

impl Packable for bool

impl Packable for i16

impl Packable for i32

impl Packable for i64

impl Packable for i8

impl Packable for u128

impl Packable for u16

impl Packable for u32

impl Packable for u64

impl Packable for u8