Zero-copy principals + CompactString partial impl
This commit is contained in:
@@ -38,6 +38,7 @@ downcast-rs = "2.0.1"
|
||||
fast-float = "0.2.0"
|
||||
erased-serde = "0.4.5"
|
||||
rkyv = { version = "0.8.10", features = ["little_endian"] }
|
||||
compact_str = "0.9.0"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
privdrop = "0.5.3"
|
||||
|
||||
@@ -11,6 +11,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use compact_str::CompactString;
|
||||
use mail_auth::{
|
||||
IpLookupStrategy,
|
||||
common::crypto::{Algorithm, HashAlgorithm},
|
||||
@@ -638,6 +639,26 @@ impl AsKey for &str {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsKey for CompactString {
|
||||
fn as_key(&self) -> String {
|
||||
self.to_string()
|
||||
}
|
||||
|
||||
fn as_prefix(&self) -> String {
|
||||
format!("{self}.")
|
||||
}
|
||||
}
|
||||
|
||||
impl AsKey for &CompactString {
|
||||
fn as_key(&self) -> String {
|
||||
self.to_string()
|
||||
}
|
||||
|
||||
fn as_prefix(&self) -> String {
|
||||
format!("{self}.")
|
||||
}
|
||||
}
|
||||
|
||||
impl AsKey for String {
|
||||
fn as_key(&self) -> String {
|
||||
self.to_string()
|
||||
|
||||
@@ -17,6 +17,7 @@ pub mod snowflake;
|
||||
pub mod topological;
|
||||
pub mod url_params;
|
||||
|
||||
use compact_str::CompactString;
|
||||
use futures::StreamExt;
|
||||
use reqwest::Response;
|
||||
use rustls::{
|
||||
@@ -364,8 +365,8 @@ impl ServerCertVerifier for DummyVerifier {
|
||||
}
|
||||
|
||||
// Basic email sanitizer
|
||||
pub fn sanitize_email(email: &str) -> Option<String> {
|
||||
let mut result = String::with_capacity(email.len());
|
||||
pub fn sanitize_email(email: &str) -> Option<CompactString> {
|
||||
let mut result = CompactString::with_capacity(email.len());
|
||||
let mut found_local = false;
|
||||
let mut found_domain = false;
|
||||
let mut last_ch = char::from(0);
|
||||
|
||||
Reference in New Issue
Block a user