Skip to main content

Module read

Module read 

Source
Expand description

Reading and checking a vCon: which form it is in, whether it is gzipped, its uuid, and whether it needs extensions the caller does not support. inspect does no I/O and returns no bytes.

Inspection, Limits and Rejection are #[non_exhaustive], so a later release can add a field or a refusal without breaking a caller. A caller reads an Inspection but does not build one:

ⓘ
let found = vcon::read::Inspection {
    form: vcon::Form::Unsigned,
    gzip: false,
    uuid: "01a07da8-c2bb-83e5-b9a2-279e0d16bc46".parse().unwrap(),
};

makes Limits with Limits::new:

ⓘ
let limits = vcon::read::Limits { inflated: 1 << 20 };

and, matching a Rejection, has an arm for refusals it does not name:

ⓘ
fn named(r: &vcon::read::Rejection) -> &'static str {
    use vcon::read::Rejection::*;
    match r {
        TooLarge => "too-large", TooDeep => "too-deep", BadGzip => "bad-gzip",
        NotJson => "not-json", DuplicateKey => "duplicate", AmbiguousForm => "ambiguous",
        NoForm => "no-form", MissingUuid => "missing-uuid", BadUuid => "bad-uuid",
        MissingCreatedAt => "missing-created-at", BadPayload => "bad-payload",
        UuidMismatch => "uuid-mismatch", BadCritical => "bad-critical",
        UnsupportedCritical(_) => "unsupported",
    }
}

Structs§

Fields
The members of a vCon that an export may copy into clear columns, read from an unsigned vCon or from the vCon inside a signed one. A member that is missing, or not of the type the vCon core draft gives it, is None.
Inspection
What a received vCon is.
Limits
Bounds on the work one inspection may do.
Party
The members of one party that Fields copies.

Enums§

Rejection
Why a received body cannot be stored as a vCon.

Constants§

MAX_JSON_DEPTH
The most arrays and objects open at once in any one JSON text read: the body, a signed payload, the vCon itself counting as one. More is refused as Rejection::TooDeep. It is below the JSON parser’s own bound of 127, so too deep is told apart from not JSON.
MAX_SIGNED_LAYERS
The most signed (JWS) layers a body may have, counting from the body to the unsigned vCon: one for a vCon signed once. A layer is added each time a signed vCon is signed again, as the vCon core draft describes for archives kept longer than their signing certificates; 64 allows one a year for 63 years. More is refused as Rejection::TooDeep before the next layer is read.

Functions§

fields
Reads the Fields of body, a vCon inspect has accepted, within the same limits. An encrypted vCon gives None: nothing in it can be read without its key.
inspect
Reads body without changing it. content_type is the media type it arrived with, if any, and supported the extension names this server accepts in critical. An encrypted vCon’s critical cannot be read and is not checked.