himalaya 0.7.0

Command-line interface for email management.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use anyhow::anyhow;
use dialoguer::Validator;
use email_address::EmailAddress;

pub(crate) struct EmailValidator;

impl<T: ToString> Validator<T> for EmailValidator {
    type Err = anyhow::Error;

    fn validate(&mut self, input: &T) -> Result<(), Self::Err> {
        let input = input.to_string();
        if EmailAddress::is_valid(&input) {
            Ok(())
        } else {
            Err(anyhow!("Invalid email address: {}", input))
        }
    }
}