macro_rules! derive_deftly_template_NetdocParseableUnverified {
({ $($driver:tt)* } [$($aoptions:tt)*] ($($future:tt)*) $($tpassthrough:tt)*) => { ... };
($($wrong:tt)*) => { ... };
}Expand description
Derive NetdocParseable for a top-level signed document
§Expected input structure
Apply this derive to the main body struct Foo,
which should meet all the requirements to derive
NetdocParseable.
Usually, the caller will provide suitable ad-hoc .verify_... methods
on FooUnverified.
The verify method should:
-
Take as an argument(s) the expected (trustworthy) signer(s), (if the document is not always just supposed to be self-signed).
-
Work directly with the fields
bodyandsigsinFooUnverified. -
Verify all the signatures, including any [
EmbeddedCert]s in the body. -
Cross-check any information that is supposed to be duplicated.
-
Determine the validity period, from the validity time information contained in the document or signatures.
-
Return
TimeRangebound<Foo>.
§Generated code
Supposing your input structure is Foo, this macro will
generate a struct FooUnverified
implementing NetdocParseable and NetdocParseableUnverified:
pub struct FooUnverified {
body: Foo,
pub sigs: SignaturesData<FooUnverified>,
}Also generated is FooUnverifiedParsedBody
and an impl of HasUnverifiedParsedBody on Foo.
These allow the generated code to call ItemStream::parse_signed
and it should not normally be necessary to use them elsewhere.
§Required top-level attributes:
-
#[deftly(netdoc(signature = TYPE))]: Type of the signature(s) section.TYPE must implement
NetdocParseable, withis_intro_item_keywordreporting every signature keyword. Normally this is achieved with#[derive_deftly(NetdocParseable)] #[deftly(netdoc(signatures))].
§Optional attributes
All the attributes supported by the NetdocParseable derive are supported.
This is a derive_deftly template. Do not invoke it directly.
To use it, write: #[derive(Deftly)] #[derive_deftly(NetdocParseableUnverified)].