add debug logic for MessageID

This commit is contained in:
Quentin 2023-07-23 19:14:42 +02:00
parent 58f491ab85
commit 5f449714f5
Signed by: quentin
GPG key ID: E9602264D639FF68

View file

@ -1,3 +1,4 @@
use std::fmt;
use nom::{
branch::alt,
bytes::complete::{tag, take_while},
@ -11,13 +12,24 @@ use crate::rfc5322::mailbox::is_dtext;
use crate::text::whitespace::cfws;
use crate::text::words::dot_atom_text;
#[derive(Debug, PartialEq, Clone)]
#[derive(PartialEq, Clone)]
pub struct MessageID<'a> {
pub left: &'a [u8],
pub right: &'a [u8],
}
impl<'a> ToString for MessageID<'a> {
fn to_string(&self) -> String {
format!("{}@{}", String::from_utf8_lossy(self.left), String::from_utf8_lossy(self.right))
}
}
impl<'a> fmt::Debug for MessageID<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple("MessageID").field(&format_args!("\"{}\"", self.to_string())).finish()
}
}
pub type MessageIDList<'a> = Vec<MessageID<'a>>;
/// Message identifier
///
/// ```abnf