diff options
-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 + } +} |