Skip to main content

FunctionDescriptor

Struct FunctionDescriptor 

Source
#[non_exhaustive]
pub struct FunctionDescriptor { pub lang: String, pub body: String, pub inputs: Vec<String>, pub signature: Signature, pub order: Option<Vec<String>>, pub extents: BTreeMap<String, Extent>, }
Expand description

A function descriptor (7) with the optional members of spec-0.4.0: signature.order and argument extent. Absent, it is the Descriptor of spec-0.3.0, byte for byte and hash for hash (From<Descriptor>, to_descriptor).

The fields are public to read; a value changed by hand is not checked again until it is parsed: FunctionDescriptor::from_value(&d.to_value()) checks it.

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.
§lang: String

code.lang, e.g. stored or formula.

§body: String

code.body, opaque to this crate.

§inputs: Vec<String>

Fully qualified names of the functions this one may read, ascending.

§signature: Signature

The signature’s arguments and return; its order and the arguments’ extents are order and extents.

§order: Option<Vec<String>>

signature.order: every argument name exactly once, the order positional arguments bind in (15.5); None when absent.

§extents: BTreeMap<String, Extent>

The arguments’ extent members, by argument name; empty when none has one.

Implementations§

Source§

impl FunctionDescriptor

Source

pub fn from_json(bytes: &[u8]) -> Result<FunctionDescriptor>

Parses a descriptor from JSON text: strict JSON, structure, canonical form (7), with order and extent and their checks (E_SCHEMA for their shapes, E_CANON_SET, E_CANON_TYPE, E_CANON_NUMBER, E_CANON_LIMIT and the lexical codes otherwise).

Source

pub fn from_value(v: &Value) -> Result<FunctionDescriptor>

Checks a parsed JSON value as a descriptor.

Source

pub fn to_value(&self) -> Value

The JSON form.

Source

pub fn canonical(&self) -> Vec<u8> ⓘ

The canonical bytes (6.2).

Source

pub fn hash(&self) -> String

The function hash: SHA-256 of the canonical bytes, lowercase hex.

Source

pub fn to_descriptor(&self) -> Option<Descriptor>

The spec-0.3.0 form, when there is no order and no extent.

Source

pub fn resolve_unit(&self, cell: &Cell) -> Result<Option<String>>

The unit of cell’s value (7.1, units.md 3), as resolve_with does for a Descriptor; None when the function does not return a number.

Trait Implementations§

Source§

impl Clone for FunctionDescriptor

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 FunctionDescriptor

Source§

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

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

impl Eq for FunctionDescriptor

Source§

impl From<Descriptor> for FunctionDescriptor

Source§

fn from(d: Descriptor) -> FunctionDescriptor

Converts to this type from the input type.
Source§

impl Hash for FunctionDescriptor

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 FunctionDescriptor

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 FunctionDescriptor

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.