Struct HashedIdGen

Source
pub struct HashedIdGen { /* private fields */ }
Expand description

a id gen implementation using hash-ing to generate part of it’s left hand side

Implementations§

Source§

impl HashedIdGen

Source

pub fn new( domain: Domain, part_unique_in_domain: SoftAsciiString, ) -> Result<HashedIdGen, EncodingError>

create a new id gen from a Domain and a unique part.

The domain is used as the right hand side of the message id and the unique_in_domain_part is concatenated with "." and a hash from the left part. The hash is generated from and integrated and a random number generated from a internal program global counter.

The tuple (domain,part_unique_in_domain) has to be world unique. I.e. for “your” domain you have to make sure the part_unique_in_domain is unique in it’s usage for message id’s.

§Error

If the domain is not ascii and puny code encoding it fails

§Design Notes (usage of part_unique_in_domain)

While the internal global counter is enough to generate seemingly unique message id’s it has two problems:

  1. the id’s are only program unique but they need to be world unique, i.e. unique between restarts of the program and multiple instances running in parallel

  2. they allow guessing the underlying number exposing private information about how many mails are send

The unique part can solves one of the problems, if it is used correctly:

  1. by providing unique bytes for part_unique_in_domain so that every time a program using this library is started different bytes are passed in all any collision in message/content id’s are prevented

The other problem is solved by hashing the counter with a random part.

Trait Implementations§

Source§

impl Clone for HashedIdGen

Source§

fn clone(&self) -> HashedIdGen

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for HashedIdGen

Source§

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

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

impl MailIdGenComponent for HashedIdGen

Source§

fn generate_message_id(&self) -> MessageId

Calls to Context::generate_message_id will be forwarded to this method.
Source§

fn generate_content_id(&self) -> MessageId

Calls to Context::generate_content_id will be forwarded to this method.

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HeaderTryFrom<T> for T

Source§

impl<F, T> HeaderTryInto<T> for F
where T: HeaderTryFrom<F>,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> Erased for T