pub struct ProviderRegistry { /* private fields */ }Expand description
A set of ProviderRules with domain lookup.
builtin seeds the well-known providers; applications can
extend it with add. User-added rules take precedence over
built-ins, so a custom rule can redefine a built-in provider.
Implementations§
Source§impl ProviderRegistry
impl ProviderRegistry
Sourcepub fn builtin() -> Self
pub fn builtin() -> Self
The built-in registry of well-known mail providers.
Only Gmail/Googlemail ignore dots; every entry folds local-part case and
uses + as its subaddress separator. All built-ins are freemail.
Returns an owned clone of a process-wide shared registry, so the rule set is constructed (and its domains IDNA-canonicalized) only once.
Sourcepub fn add(&mut self, rule: ProviderRule)
pub fn add(&mut self, rule: ProviderRule)
Add a rule. User-added rules take precedence over earlier ones.
Sourcepub fn with(self, rule: ProviderRule) -> Self
pub fn with(self, rule: ProviderRule) -> Self
Builder-style add.
Sourcepub fn lookup(&self, domain: &str) -> Option<&ProviderRule>
pub fn lookup(&self, domain: &str) -> Option<&ProviderRule>
Look up the rule for a domain, or None if no provider matches.
Most-recently-added rules win, so a custom rule overrides a built-in for the same domain. The domain is canonicalized to IDNA-ASCII once, so Unicode and punycode spellings resolve to the same rule.
Trait Implementations§
Source§impl Clone for ProviderRegistry
impl Clone for ProviderRegistry
Source§fn clone(&self) -> ProviderRegistry
fn clone(&self) -> ProviderRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more