aztec-nr - noir_aztec::state_vars::owned

Struct Owned

pub struct Owned<V, Context> {
    pub context: Context,
    /* private fields */
}

A wrapper state variable that is to be used with variables that implement the OwnedStateVariable trait.

Example usage:

#[storage]
struct Storage {
    balance: Owned<PrivateSet<UintNote, Context>, Context>,
}

To access the underlying owned state variable for a specific owner, use the at method:

let user_balance = storage.balance.at(user_address);

For more information on ownership, see the documentation for the OwnedStateVariable trait.

Type Parameters

  • V - The underlying type that implements OwnedStateVariable<Context> (e.g., PrivateSet, PrivateMutable).
  • Context - The execution context type (e.g., PublicContext, PrivateContext, UtilityContext). The context determines which methods of the state variable are available.

Fields

context: Context

Implementations

impl<Context, V> Owned<V, Context>

pub fn at(self, owner: AztecAddress) -> V
where V: OwnedStateVariable<Context>

Returns an instance of the underlying owned state variable for a given owner.

Trait implementations

impl<Context, V> StateVariable<1, Context> for Owned<V, Context>

pub fn new(context: Context, storage_slot: Field) -> Self pub fn get_storage_slot(self) -> Field