Skip to main content

read

Function read 

Source
pub fn read<T: DeserializeOwned>(
    registry: &Registry,
    document: &Value,
) -> Result<Read<T>, ReadError>
Expand description

Read a document from another server into a vocabulary type.

The document is normalised first, so it is read by what its keys mean rather than how the sender spelled them: "as:sensitive", a term aliased to it, and "sensitive" all arrive in the same field, and a type written with a prefix, such as "fep:QuoteRequest", arrives as the type it names. Only the contexts registry holds are resolved; nothing is fetched.

Verify signatures and proofs on document before reading it, not on the value this returns. Normalising rewrites the document, and a signature covers the bytes that were signed.

§Errors

ReadError::JsonLd when the document cannot be processed — it uses @graph, @included or @reverse, or exceeds a processing limit — and ReadError::Shape when it is not the shape of T.