#[non_exhaustive]pub struct Reference {
pub ns: String,
pub fn_name: String,
pub args: Args,
pub fn_hash: Option<String>,
pub asof: Option<String>,
}Expand description
A cell reference (4.3) with the optional pin of spec-0.4.2: fn_hash, the function the
reference is pinned to, whatever its name is bound to (5.1, 5.8). Unpinned, it is the
CellRef of spec-0.4.1 (From<CellRef>, Reference::to_cell_ref).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.ns: StringThe namespace.
fn_name: StringThe function name within the namespace.
args: ArgsThe arguments, typed by the function’s signature.
fn_hash: Option<String>The pin: the function hash the reference is pinned to, or None.
asof: Option<String>The transaction time asked for; None means now.
Implementations§
Source§impl Reference
impl Reference
Sourcepub fn from_json(bytes: &[u8]) -> Result<Reference>
pub fn from_json(bytes: &[u8]) -> Result<Reference>
Parses a reference from JSON text: strict JSON, structure (fn_hash a string,
E_SCHEMA), canonical form in JCS order (args, asof, fn, fn_hash as 64
lowercase hex digits (E_CANON_HEX), ns), then the 512-character function name.
Sourcepub fn new(
ns: impl Into<String>,
fn_name: impl Into<String>,
args: Args,
) -> Reference
pub fn new( ns: impl Into<String>, fn_name: impl Into<String>, args: Args, ) -> Reference
A reference to ns/fn_name with these arguments, unpinned and as of now; set
fn_hash and asof to pin it or ask as of a time. Not
checked: crate::format_reference writes what it is given.
Sourcepub fn canonical(&self) -> Vec<u8> ⓘ
pub fn canonical(&self) -> Vec<u8> ⓘ
The canonical bytes (6.2). A pinned reference without asof has the canonical bytes,
and so the id, of the cell it denotes.
Sourcepub fn cell(&self) -> Option<Cell>
pub fn cell(&self) -> Option<Cell>
The cell a pinned reference denotes; None when it is not pinned (resolve its name
with Reference::resolve).
Sourcepub fn resolve(&self, fn_hash: &str) -> Result<Cell>
pub fn resolve(&self, fn_hash: &str) -> Result<Cell>
The cell this reference denotes once its name has resolved to fn_hash. A pinned
reference denotes its pin’s cell only: another hash is E_FN_HASH_MISMATCH.
Sourcepub fn to_cell_ref(&self) -> Option<CellRef>
pub fn to_cell_ref(&self) -> Option<CellRef>
The spec-0.4.1 form, when the reference is not pinned.