Module sui::object_bag
Similar to sui::bag, an ObjectBag is a heterogeneous map-like collection. But unlike
sui::bag, the values bound to these dynamic fields must be objects themselves. This allows
for the objects to still exist in storage, which may be important for external tools.
The difference is otherwise not observable from within Move.
use std::ascii;
use std::bcs;
use std::option;
use std::string;
use std::vector;
use sui::address;
use sui::dynamic_field;
use sui::dynamic_object_field;
use sui::hex;
use sui::object;
use sui::tx_context;
Struct ObjectBag
public struct ObjectBag has key, store
Click to open
Fields
- id: sui::object::UID
- the ID of this bag
- size: u64
- the number of key-value pairs in the bag
Constants
const EBagNotEmpty: u64 = 0;
Function new
Creates a new, empty bag
public fun new(ctx: &mut sui::tx_context::TxContext): sui::object_bag::ObjectBag
Function add
Adds a key-value pair to the bag bag: &mut ObjectBag.
Aborts with sui::dynamic_field::EFieldAlreadyExists if the bag already has an entry with
that key k: K.
public fun add<K: copy, drop, store, V: key, store>(bag: &mut sui::object_bag::ObjectBag, k: K, v: V)