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
impl ReceiptBuilder
Sourcepub fn new() -> ReceiptBuilder
pub fn new() -> ReceiptBuilder
A builder with no members set.
Sourcepub fn valid(self, valid: Args) -> Self
pub fn valid(self, valid: Args) -> Self
The valid-time arguments, echoed from the cell’s arguments ({} if none).
Sourcepub fn publisher(self, publisher: impl Into<String>) -> Self
pub fn publisher(self, publisher: impl Into<String>) -> Self
The namespace that owns the function; must equal the cell’s ns.
Sourcepub fn signer_host(self, host: impl Into<String>) -> Self
pub fn signer_host(self, host: impl Into<String>) -> Self
The host publishing the signing key: computed_by is <host>#<key id>.
Sourcepub fn inputs<I, S>(self, inputs: I) -> Self
pub fn inputs<I, S>(self, inputs: I) -> Self
The inputs entries, receipt hashes and slice entries (slice:<slice id>:<members hash>, see crate::Manifest::entry); must be strictly ascending.
Sourcepub fn summary(self, summary: impl Into<String>) -> Self
pub fn summary(self, summary: impl Into<String>) -> Self
One human sentence saying what the value is.
Sourcepub fn source(self, source: Source) -> Self
pub fn source(self, source: Source) -> Self
The source member (8.1, spec-0.6.0): where the value was taken from. Only with no
inputs; sign refuses it otherwise (E_SCHEMA).
Sourcepub fn withdrawn(self, reason: &str) -> Self
pub fn withdrawn(self, reason: &str) -> Self
withdrawn (8.1, spec-0.7.0, R1): the reason the cell is withdrawn, the null version of
the cell. Only sign_withdrawal signs it; sign
refuses a builder that has it. It replaces value.
Sourcepub fn sign(&self, key: &SigningKey) -> Result<Receipt>
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. A builder with withdrawn is E_SCHEMA: it
signs with sign_withdrawal.
Sourcepub fn sign_withdrawal(&self, key: &SigningKey) -> Result<Withdrawal>
pub fn sign_withdrawal(&self, key: &SigningKey) -> Result<Withdrawal>
Checks the members as Withdrawal::from_json does, then signs the payload (8.3) with
key. The withdrawal’s computed_by is <signer host>#<key.key_id()>.
The builder is a withdrawal’s: withdrawn is set, value is not (E_SCHEMA), and inputs
is empty (E_SCHEMA, a stored cell’s only). Every other member is as for sign:
an unset one is E_SCHEMA, and a publisher or time order that breaks 10.1 steps 4 is its
code. The reason follows the summary rules (E_SCHEMA when empty, E_CANON_STRING or
E_CANON_LIMIT otherwise).