~matthiasbeyer/maildir

cfdcd49b59401ca77f8a0d77874a6691b0777c8b — Kartikaya Gupta 2 years ago dd7e190
Add a date() function
1 files changed, 10 insertions(+), 0 deletions(-)

M src/lib.rs
M src/lib.rs => src/lib.rs +10 -0
@@ 117,6 117,16 @@ impl MailEntry {
        }
    }

    pub fn date(&mut self) -> Result<i64, MailEntryError> {
        self.read_data()?;
        let headers = self.headers()?;
        let date = headers.get_first_value("Date")?;
        match date {
            Some(ts) => dateparse(&ts).map_err(MailEntryError::from),
            None => Err("No Date header found")?,
        }
    }

    pub fn flags(&self) -> &str {
        &self.flags
    }