1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! Module dedicated to Notmuch email envelope flags.
//!
//! This module contains flag-related mapping functions from the
//! [notmuch] crate types.

use log::debug;
use notmuch::Message;

use crate::flag::Flags;

impl Flags {
    pub fn from_notmuch_msg(msg: &Message) -> Self {
        msg.tags()
            .filter_map(|ref tag| match tag.parse() {
                Ok(flag) => Some(flag),
                Err(err) => {
                    debug!("cannot parse notmuch tag {tag}: {err}");
                    debug!("{err:?}");
                    None
                }
            })
            .collect()
    }
}