pub struct MessageInstance {
pub m: u32,
pub hashes: Vec<MessageHash>,
pub recipe: Option<Recipe>,
}Expand description
A parsed Message-Instance header field (§9).
Records the hashes of the message content at one revision and, for a
revision made by a Reviser, the recipe that recreates the previous
revision. Produced by MessageInstance::parse when a message is parsed,
by MessageInstance::from_message and MessageInstance::from_recipe,
and by the signers in Dkim2Signed::message_instance.
Fields§
§m: u32m=: revision number, starting at 1 for the originator (§9.1).
hashes: Vec<MessageHash>h=: header and body hashes of this revision, one entry per hash
algorithm (§9.3).
recipe: Option<Recipe>r=: recipe that recreates the previous revision from this one, or
None if the tag is absent (§9.2).
Implementations§
Source§impl MessageInstance
impl MessageInstance
Sourcepub fn write(&self, writer: &mut impl Writer)
pub fn write(&self, writer: &mut impl Writer)
Writes the complete Message-Instance header field on one line,
terminated by CRLF. The recipe, if any, is written as base64-encoded
JSON in the r= tag as it is, including one accepted leniently when
parsed; the signers check Recipe::validate
on recipes they generate before signing.
Source§impl MessageInstance
impl MessageInstance
Sourcepub fn parse(header: &[u8]) -> Result<MessageInstance>
pub fn parse(header: &[u8]) -> Result<MessageInstance>
Parses a single Message-Instance header field value (without the
field name).
The value is a Tag=Value list (§8) with the same rules as
Signature::parse. Hash names are case-sensitive; unsupported ones
are kept as HashName::Unknown. The r= recipe is base64-decoded
and parsed and validated as JSON (§5).
§Errors
Returns Dkim2Error::InstanceSyntax for a malformed tag list or
value or a repeated tag, Dkim2Error::InstanceTagMissing if m=
or h= is missing, Dkim2Error::InstanceDuplicateHash if h=
repeats a hash algorithm, and Dkim2Error::InvalidJson if the
recipe is not valid JSON or does not follow the recipe schema.
Source§impl MessageInstance
impl MessageInstance
Sourcepub fn from_message(
message: &AuthenticatedMessage<'_>,
original: Option<&AuthenticatedMessage<'_>>,
hashes: &[Dkim2Hash],
) -> Result<Option<Self>>
pub fn from_message( message: &AuthenticatedMessage<'_>, original: Option<&AuthenticatedMessage<'_>>, hashes: &[Dkim2Hash], ) -> Result<Option<Self>>
Builds the Message-Instance a signer adds to message, if one is
needed (§12.1).
Without original, returns an instance with m=1 if message has no
Message-Instance yet, and None otherwise. With original (the
message before modification), computes Recipe::diff and returns
a new instance carrying the recipe when the signed content changed,
or when message has no instance yet. The instance number is one
more than the highest existing m= and the hashes use hashes.
§Errors
Returns Dkim2Error::HeaderNotRepresentable when Recipe::diff
cannot record a changed header field.
Sourcepub fn from_recipe(
message: &AuthenticatedMessage<'_>,
recipe: Option<Recipe>,
hashes: &[Dkim2Hash],
) -> Option<Self>
pub fn from_recipe( message: &AuthenticatedMessage<'_>, recipe: Option<Recipe>, hashes: &[Dkim2Hash], ) -> Option<Self>
Builds a Message-Instance for message carrying recipe.
Returns None only when recipe is None and message already has
a Message-Instance. The instance number is one more than the highest
existing m= and the hashes of message use hashes.
Trait Implementations§
Source§impl Clone for MessageInstance
impl Clone for MessageInstance
Source§impl Debug for MessageInstance
impl Debug for MessageInstance
Source§impl Default for MessageInstance
impl Default for MessageInstance
Source§impl Display for MessageInstance
impl Display for MessageInstance
impl Eq for MessageInstance
Source§impl HeaderWriter for MessageInstance
impl HeaderWriter for MessageInstance
Source§fn write_header(&self, writer: &mut impl Writer)
fn write_header(&self, writer: &mut impl Writer)
writer.Source§impl PartialEq for MessageInstance
impl PartialEq for MessageInstance
impl StructuralPartialEq for MessageInstance
Auto Trait Implementations§
impl Freeze for MessageInstance
impl RefUnwindSafe for MessageInstance
impl Send for MessageInstance
impl Sync for MessageInstance
impl Unpin for MessageInstance
impl UnsafeUnpin for MessageInstance
impl UnwindSafe for MessageInstance
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more