Skip to main content

Module ledger_obj

Module ledger_obj 

Source
Expand description

§Ledger Object Field Retrieval Module (by slot)

Typed accessors for reading fields from a ledger object that has been cached into a slot (via cache_le). get_field and get_field_optional are generic over any type implementing crate::fields::decoder::FromLedger — see crate::fields::decoder for how a type opts into that.

Functions§

get_blob_field
Retrieves a Blob<N> field from the ledger object cached in slot, writing the host’s bytes directly into the returned Blob<N>’s own storage. See the comment above this function for why Blob<N> gets a dedicated accessor instead of using get_field.
get_blob_field_optional
Optional variant of get_blob_field: returns Ok(None) if the field is not present, otherwise behaves identically (including the direct-write zero-copy behavior). Implemented in terms of get_blob_field itself rather than duplicating its body — Error::FieldNotFound round-trips exactly through Error::from_code/.code() (both are just FIELD_NOT_FOUND), so translating that one error case into None is all this needs to do.
get_field
Retrieves a field from the ledger object cached in slot using an SField constant.
get_field_optional
Retrieves an optionally present field from the ledger object cached in slot.