pub struct ContactsCache {
pub by_email: HashMap<String, Contact>,
pub last_refreshed: Option<DateTime<Utc>>,
}Expand description
JSON-backed contact cache. Keyed by lowercase email.
Fields§
§by_email: HashMap<String, Contact>§last_refreshed: Option<DateTime<Utc>>Implementations§
Source§impl ContactsCache
impl ContactsCache
Sourcepub fn default_path() -> Result<PathBuf, CoreError>
pub fn default_path() -> Result<PathBuf, CoreError>
${XDG_CACHE_HOME:-~/.cache}/pidge/contacts.json.
pub fn load() -> Result<Self, CoreError>
pub fn load_from(path: &Path) -> Result<Self, CoreError>
pub fn save(&self) -> Result<(), CoreError>
pub fn save_to(&self, path: &Path) -> Result<(), CoreError>
Sourcepub fn upsert(
&mut self,
email: &str,
display_name: &str,
seen_at: DateTime<Utc>,
source: ContactSource,
)
pub fn upsert( &mut self, email: &str, display_name: &str, seen_at: DateTime<Utc>, source: ContactSource, )
Insert one observation. Email is lowercased; display name is only
applied when non-empty (we never overwrite a known name with "").
last_seen advances to the later of the existing and new values so
out-of-order refreshes converge to the right state.
pub fn mark_refreshed(&mut self, at: DateTime<Utc>)
Trait Implementations§
Source§impl Clone for ContactsCache
impl Clone for ContactsCache
Source§impl Debug for ContactsCache
impl Debug for ContactsCache
Source§impl Default for ContactsCache
impl Default for ContactsCache
Source§impl<'de> Deserialize<'de> for ContactsCache
impl<'de> Deserialize<'de> for ContactsCache
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ContactsCache
impl RefUnwindSafe for ContactsCache
impl Send for ContactsCache
impl Sync for ContactsCache
impl Unpin for ContactsCache
impl UnsafeUnpin for ContactsCache
impl UnwindSafe for ContactsCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more