Struct mail_core::default_impl::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
sourceimpl HashedIdGen
impl HashedIdGen
sourcepub fn new(
domain: Domain,
part_unique_in_domain: SoftAsciiString
) -> Result<Self, EncodingError>
pub fn new(
domain: Domain,
part_unique_in_domain: SoftAsciiString
) -> Result<Self, 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:
-
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
-
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:
- 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
sourceimpl Clone for HashedIdGen
impl Clone for HashedIdGen
sourcefn clone(&self) -> HashedIdGen
fn clone(&self) -> HashedIdGen
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for HashedIdGen
impl Debug for HashedIdGen
sourceimpl MailIdGenComponent for HashedIdGen
impl MailIdGenComponent for HashedIdGen
sourcefn generate_message_id(&self) -> MessageId
fn generate_message_id(&self) -> MessageId
Context::generate_message_id
will be forwarded to this method.sourcefn generate_content_id(&self) -> ContentId
fn generate_content_id(&self) -> ContentId
Context::generate_content_id
will be forwarded to this method.