Skip to main content

Module envelope

Module envelope 

Source
Expand description

Envelopes (SPEC 5.5) as the mesh writes them, and Reply: an HTTP answer before it is an HTTP response.

Every envelope is written as canonical JSON (JCS), so the same statement always has the same bytes (a call and a cell URI for one cell give byte-identical bodies). The embedded receipt is the stored receipt, unchanged.

Structs§

Bytes
A cheaply cloneable and sliceable chunk of contiguous memory.
Reply
An answer: HTTP status, body and the headers the mesh sets.

Enums§

Cache
How a reply may be cached.

Constants§

BAD_REQUEST_CODES
The parse codes a bad_request may carry at /cell (SPEC 5.5; E_CANON_HEX for a pin since spec-0.4.2).
CALL_CODES
The codes a bad_request may carry besides BAD_REQUEST_CODES since spec-0.5.0: a key not canonical under its normalisation (16.4), a malformed key encoding (16.5) and an ambiguous short id (16.8).
JSON
The media type of JSON bodies.

Functions§

answer_reply
The reply of an answer built with the core’s envelope builder (spec-0.4.2), with its status.
bad_request
A bad_request envelope.
bad_request_reply
The reply of a bad_request envelope.
error
An error envelope.
error_answer_reply
The reply of an error answer with code, the function hash echoed.
error_reply
The reply of an error envelope.
error_status
The HTTP status of an error envelope with code: 503 when something the mesh depends on is unavailable (the store, another mesh, a key document), 500 otherwise.
is_error_code
Whether code may be an error envelope’s error: any code of 10.2 but E_ENVELOPE and the request codes E_JOB_UNKNOWN, E_SLICE_AT_CELL and E_NAME_UNBOUND, and the codes of spec-0.5.0 no error envelope carries (5.5): E_NAMESPACE_SUSPENDED, the class codes and CALL_CODES.
is_request_code
Whether code may be a bad_request’s error at /cell (the parse codes of BAD_REQUEST_CODES and CALL_CODES, and E_SLICE_AT_CELL).
name_unbound_reply
The reply of a not_covered answer with E_NAME_UNBOUND (spec-0.4.2).
not_covered
A not_covered envelope, with the evaluation’s fault if it faulted.
not_yet_reply
503 for a read of a background build before that build has finished its first run (CONTRACT-0.4.9 H2 to H4): Retry-After in seconds (1 to 300), never cached. A request never builds the answer itself.
ok
An ok envelope around the receipt’s bytes (its JSON, unchanged).
payment_required
A payment_required envelope.
pending
A pending envelope.
rate_limited
A rate_limited envelope.
rate_limited_reply
The reply of a rate_limited envelope.
stale
A stale envelope.
trust_label_of
The trust label of spec-0.4.2 for a receipt this mesh serves (SPEC 5.5): relayed when the receipt has a source (spec-0.6.0); primary exactly when the signer’s host is the namespace’s host and there are no inputs; computed when this mesh signed it (it evaluated the cell); unverified otherwise (this mesh does not recompute other meshes’ receipts).
trust_of
trust for a receipt this mesh serves (SPEC 5.5): primary exactly when the signer’s host is the namespace’s host and there are no inputs; verified for a receipt this mesh computed (computed_by its own host); unverified otherwise.
unlicensed
An unlicensed envelope.
with_fn_hash
An answer with the function hash echoed (SPEC 5.5: required for a pinned request, allowed otherwise), when one is given.
with_resolved
reply with the resolved member (5.5, 16.7) when its envelope may carry one (ok, stale, not_covered, unlicensed, payment_required, error); any other reply as it is. The member is core’s (Answer::with_resolved), written where JCS puts it.