pub struct CloseGroupCache {
pub peers: Vec<CachedCloseGroupPeer>,
pub saved_at_epoch_secs: u64,
}Expand description
Persisted close group snapshot with trust scores.
Saved periodically and on shutdown. Loaded on startup to reconnect to the same trusted close group peers, preserving close group consistency across restarts.
Fields§
§peers: Vec<CachedCloseGroupPeer>Close group peers with their trust scores
saved_at_epoch_secs: u64When this snapshot was saved (seconds since UNIX epoch)
Implementations§
Source§impl CloseGroupCache
impl CloseGroupCache
Sourcepub async fn save_to_dir(&self, dir: &Path) -> Result<()>
pub async fn save_to_dir(&self, dir: &Path) -> Result<()>
Save the cache to {dir}/close_group_cache.json.
Uses tempfile::NamedTempFile::persist for atomicity: the temp file
has a unique name (safe under concurrent saves) and persist is an
atomic rename on Unix and a replace-then-rename on Windows.
Sourcepub async fn load_from_dir(dir: &Path) -> Result<Option<Self>>
pub async fn load_from_dir(dir: &Path) -> Result<Option<Self>>
Load the cache from {dir}/close_group_cache.json.
Returns None if the file doesn’t exist (fresh start).
Trait Implementations§
Source§impl Clone for CloseGroupCache
impl Clone for CloseGroupCache
Source§fn clone(&self) -> CloseGroupCache
fn clone(&self) -> CloseGroupCache
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CloseGroupCache
impl Debug for CloseGroupCache
Source§impl<'de> Deserialize<'de> for CloseGroupCache
impl<'de> Deserialize<'de> for CloseGroupCache
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 CloseGroupCache
impl RefUnwindSafe for CloseGroupCache
impl Send for CloseGroupCache
impl Sync for CloseGroupCache
impl Unpin for CloseGroupCache
impl UnsafeUnpin for CloseGroupCache
impl UnwindSafe for CloseGroupCache
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