Skip to main content

MessageInstance

Struct MessageInstance 

Source
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: u32

m=: 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, ordered by group (§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

Source

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

Source

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. h= entries are split into |-separated groups of ,-separated entries. 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, Dkim2Error::InvalidJson if the recipe is not valid JSON, and Dkim2Error::InvalidRecipe if it is valid JSON that does not follow the recipe rules.

Source§

impl MessageInstance

Source

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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MessageInstance

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MessageInstance

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for MessageInstance

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for MessageInstance

Source§

impl HeaderWriter for MessageInstance

Source§

fn write_header(&self, writer: &mut impl Writer)

Writes the complete header field, including the field name and the trailing CRLF, to writer.
Source§

fn to_header(&self) -> String

Returns the complete header field as a string, including the field name and the trailing CRLF. Invalid UTF-8 is replaced with U+FFFD.
Source§

impl PartialEq for MessageInstance

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MessageInstance

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more