Skip to main content

Module locator

Module locator 

Source
Expand description

Inner field access: encode a path (sfield codes and array indices) into the compact binary format the host understands, then read a field like Memos[0].MemoType.

Two APIs share the same buffer layout:

  • TxPathBuilder and LedgerPathBuilder are the recommended fluent builders. Each is rooted at its context โ€” ctx.tx().path() for the current transaction, obj.path() or ctx.escrow().path() for a ledger object โ€” so no bare buffer escapes and the terminal get always dispatches to the host function matching that context. Field codes come from typed SField constants:
    use xrpl_common_stdlib::current_tx::traits::TransactionCommonFields;
    use xrpl_common_stdlib::sfield;
    // Read Memos[0].MemoData from the current transaction.
    let data = tx.path()
        .field(sfield::Memos)
        .index(0)
        .field(sfield::MemoData)
        .get::<u32>();
  • Locator itself is the lower-level buffer: pack values in and pass as_ptr / num_packed_bytes to a raw host call. Prefer the builder unless you need that manual control.
    use xrpl_common_stdlib::fields::locator::Locator;
    use xrpl_common_stdlib::sfield;
    let mut l = Locator::new();
    l.pack(sfield::Memos);
    l.pack(0);
    l.pack(sfield::MemoType);

Structsยง

LedgerPathBuilder
Fluent builder for reading an inner field from a ledger object โ€” either the object the contract is attached to, or one cached into a slot.
Locator
A Locator encodes a path to an inner field as a sequence of 4-byte packed values (sfield codes or array indices) in a compact binary format understood by the host.
TxPathBuilder
Fluent builder for reading an inner field from the current transaction.