Skip to main content

NetdocParseableSignatures

Trait NetdocParseableSignatures 

Source
pub trait NetdocParseableSignatures: Sized {
    type HashesAccu: Default + Debug + Clone;

    // Required methods
    fn is_item_keyword(kw: KeywordRef<'_>) -> bool;
    fn from_items<'s>(
        input: &mut ItemStream<'s>,
        signed_doc_body: SignedDocumentBody<'s>,
        sig_hashes: &mut Self::HashesAccu,
        stop_at: StopAt<impl StopPredicate>,
    ) -> Result<Self, ErrorProblem>;
}
Expand description

The signatures section of a network document, that can be parsed

Required Associated Types§

Source

type HashesAccu: Default + Debug + Clone

The type used to accumulate document hashes during parsing

Initialised to Default at the start of parsing, by the parse2 core

Each item in a signatures section is parsed by a SignatureItemParseable impl. That impl definites an item-specific HashAccu type.

The derived signatures section parsing code finds the item-specific hash accumulator type <ITEM as SignatureItemParseable>::HashAccu via AsMut: NetdocParseableSignatures::HashesAccu must impl AsMut for each SignatureItemParseable::HashAccu.

For a signatures section that can contain multiple signatures with different hashes, the AsMut will normally be derived by derive_more::AsMut. For a document with only one hash type, NetdocParseableSignatures::HashesAccu and SignatureItemParseable::HashAccu can be the same newtype, deriving AsMut<Self>.

During signature verification, the document-specific verification could should throw VerifyFailed::Bug if a hash needed for a signature item wasn’t populated. (This isn’t possible if each item’s SignatureItemParseable::from_unparsed_and_body always calculates and stores the hash.)

Required Methods§

Source

fn is_item_keyword(kw: KeywordRef<'_>) -> bool

Is kw one of this signature section’s keywords

Source

fn from_items<'s>( input: &mut ItemStream<'s>, signed_doc_body: SignedDocumentBody<'s>, sig_hashes: &mut Self::HashesAccu, stop_at: StopAt<impl StopPredicate>, ) -> Result<Self, ErrorProblem>

Parse the signature section from a stream of items

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§