Skip to main content

ReceiptBuilder

Struct ReceiptBuilder 

Source
pub struct ReceiptBuilder { /* private fields */ }
Expand description

The members of a receipt before it is signed; sign is the only way to turn it into a Receipt.

Every member of 8.1 has a setter except proto (always datumesh/1), type (the value’s type), sig (made by sign) and computed_by: that one is derived, as <signer host>#<key id of the signing key>, so a receipt naming another key than the one that signed it cannot be built. inputs defaults to empty (a stored cell); every other member must be set.

Nothing is repaired: sign checks the members exactly as Receipt::from_json checks a parsed receipt (steps 2-4 of 10.1) and returns the error it would report.

Implementations§

Source§

impl ReceiptBuilder

Source

pub fn new() -> ReceiptBuilder

A builder with no members set.

Source

pub fn cell(self, cell: Cell) -> Self

The cell answered (no slices).

Source

pub fn value(self, value: Scalar) -> Self

The value; also sets type.

Source

pub fn valid(self, valid: Args) -> Self

The valid-time arguments, echoed from the cell’s arguments ({} if none).

Source

pub fn asof(self, asof: impl Into<String>) -> Self

The transaction time answered as of.

Source

pub fn tx(self, tx: impl Into<String>) -> Self

When the value was recorded.

Source

pub fn issued(self, issued: impl Into<String>) -> Self

When the receipt is signed.

Source

pub fn publisher(self, publisher: impl Into<String>) -> Self

The namespace that owns the function; must equal the cell’s ns.

Source

pub fn signer_host(self, host: impl Into<String>) -> Self

The host publishing the signing key: computed_by is <host>#<key id>.

Source

pub fn inputs<I, S>(self, inputs: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Receipt hashes of the inputs; must be strictly ascending.

Source

pub fn licence(self, licence: impl Into<String>) -> Self

An SPDX identifier or an https URL.

Source

pub fn summary(self, summary: impl Into<String>) -> Self

One human sentence saying what the value is.

Source

pub fn sign(&self, key: &SigningKey) -> Result<Receipt>

Checks the members as Receipt::from_json does, then signs the payload (8.3) with key. The receipt’s computed_by is <signer host>#<key.key_id()>.

Errors: E_SCHEMA for a member not set (path $), otherwise the code and path from_json reports for the same members.

Trait Implementations§

Source§

impl Clone for ReceiptBuilder

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 ReceiptBuilder

Source§

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

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

impl Default for ReceiptBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.