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
Receipt hashes of the inputs; 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 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.