pub struct Slice { /* private fields */ }Expand description
A slice object (4.4, spec-0.4.0): a cell object with at least one argument open ("*")
or bounded by a range object {"hi", "lo", "type"}, or a version slice
{"cell", "from", "to"}. Its slice id is SHA-256 of its canonical bytes; for an
unbounded slice it is the id of the cell object with the markers.
An object with exactly the members cell, from and to is a version slice; any other is
read as a cell object. Within a cell object, an argument that is an object with exactly
hi, lo and type is a range; any other object is read as a typed scalar.
Implementations§
Source§impl Slice
impl Slice
Sourcepub fn from_json(bytes: &[u8]) -> Result<Slice>
pub fn from_json(bytes: &[u8]) -> Result<Slice>
Parses a slice object from JSON text: strict JSON, structure (E_SCHEMA), canonical
form in JCS order (the codes of 3 and 4.5; a range’s type, then hi, then lo;
E_CANON_TYPE for a boolean or blob range), then E_SLICE for a cell object without an
open or ranged argument, or a version slice whose cell has one.
Sourcepub fn from_value(v: &Value) -> Result<Slice>
pub fn from_value(v: &Value) -> Result<Slice>
Checks a parsed JSON value as a slice object.
Sourcepub fn function_name(&self) -> String
pub fn function_name(&self) -> String
The fully qualified name of the slice’s function, <ns>/<fn> (of the version slice’s
cell for a version slice).
Sourcepub fn is_version_slice(&self) -> bool
pub fn is_version_slice(&self) -> bool
Whether this is a version slice ({"cell", "from", "to"}).
Sourcepub fn contains(&self, receipt: &Receipt) -> bool
pub fn contains(&self, receipt: &Receipt) -> bool
Whether receipt belongs to the slice (10.1 step 7.5): for a cell object, the same
ns, fn and fn_hash, the same argument names, bound arguments equal, ranged
arguments of the range’s type and within it, any value for an open argument; for a
version slice, the same cell with a tx in [from, to]. That no two members of a
slice are one cell is a property of the member set, checked by verify.