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

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

Implementations

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Calls to Context::generate_message_id will be forwarded to this method.
Calls to Context::generate_content_id will be forwarded to this method.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.