diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-01-02 15:57:06 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-01-02 18:46:03 +0100 |
commit | 8e15f356a4a1ddbcc9d5489cac942aab8417f666 (patch) | |
tree | 3414818773662f6f2834459ac1ece5e5786154a1 | |
parent | 865b66ef6521aab1941eb4ead306a864884a0a41 (diff) |
Add more impls on MessageId type
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | lib/domain/libimagmail/src/mid.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/domain/libimagmail/src/mid.rs b/lib/domain/libimagmail/src/mid.rs index 6a0b676f..3d579ef1 100644 --- a/lib/domain/libimagmail/src/mid.rs +++ b/lib/domain/libimagmail/src/mid.rs @@ -22,12 +22,29 @@ /// Message IDs are used to identfy emails uniquely, so we should at least have a type for /// representing them and make handling a bit easier. /// -#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct MessageId(String); +impl MessageId { + pub fn new(s: String) -> Self { + MessageId(s) + } +} + impl Into<String> for MessageId { fn into(self) -> String { self.0 } } +impl From<String> for MessageId { + fn from(s: String) -> Self { + MessageId(s) + } +} + +impl AsRef<str> for MessageId { + fn as_ref(&self) -> &str { + &self.0 + } +} |