From 8e15f356a4a1ddbcc9d5489cac942aab8417f666 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 2 Jan 2020 15:57:06 +0100 Subject: Add more impls on MessageId type Signed-off-by: Matthias Beyer --- lib/domain/libimagmail/src/mid.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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 for MessageId { fn into(self) -> String { self.0 } } +impl From for MessageId { + fn from(s: String) -> Self { + MessageId(s) + } +} + +impl AsRef for MessageId { + fn as_ref(&self) -> &str { + &self.0 + } +} -- cgit v1.2.3