Skip to main content

Reference

Struct Reference 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§ns: String

The namespace.

§fn_name: String

The function name within the namespace.

§args: Args

The 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

Source

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.

Source

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.

Source

pub fn to_value(&self) -> Value

The JSON form.

Source

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.

Source

pub fn cell(&self) -> Option<Cell>

The cell a pinned reference denotes; None when it is not pinned (resolve its name with Reference::resolve).

Source

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.

Source

pub fn to_cell_ref(&self) -> Option<CellRef>

The spec-0.4.1 form, when the reference is not pinned.

Trait Implementations§

Source§

impl Clone for Reference

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Reference

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Reference

Source§

impl From<CellRef> for Reference

Source§

fn from(r: CellRef) -> Reference

Converts to this type from the input type.
Source§

impl Hash for Reference

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Reference

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Reference

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.