pub struct DhtStateSnapshot {
pub nodes: Vec<DhtNodeInfo>,
pub token_secret: [u8; 20],
pub last_bootstrap_epoch_secs: Option<u64>,
pub total_nodes: usize,
}Expand description
Snapshot of DHT (Distributed Hash Table) routing state for persistence.
Captures the current state of DHT nodes, token secret, and bootstrap timing to allow quick resumption without full bootstrap on restart.
§Serialization
This struct implements Serialize/Deserialize for JSON persistence alongside
session data. Use to_json_string() and from_json_string() for conversion.
Fields§
§nodes: Vec<DhtNodeInfo>Known DHT nodes in the routing table
token_secret: [u8; 20]Current token secret used for DHT get_peers requests (20 bytes)
last_bootstrap_epoch_secs: Option<u64>Unix epoch timestamp of last successful bootstrap, if any
total_nodes: usizeTotal number of nodes in the snapshot (convenience field)
Implementations§
Source§impl DhtStateSnapshot
impl DhtStateSnapshot
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Create an empty snapshot (for when DHT is unavailable or not initialized).
Returns a snapshot with no nodes and zeroed token secret, suitable as a default or placeholder value.
Sourcepub fn new(
nodes: Vec<DhtNodeInfo>,
token_secret: [u8; 20],
last_bootstrap_epoch_secs: Option<u64>,
) -> Self
pub fn new( nodes: Vec<DhtNodeInfo>, token_secret: [u8; 20], last_bootstrap_epoch_secs: Option<u64>, ) -> Self
Create a snapshot from node data with automatic total_nodes calculation.
§Arguments
nodes- Vector of known DHT nodestoken_secret- Current 20-byte token secretlast_bootstrap- Optional timestamp of last bootstrap
Trait Implementations§
Source§impl Clone for DhtStateSnapshot
impl Clone for DhtStateSnapshot
Source§fn clone(&self) -> DhtStateSnapshot
fn clone(&self) -> DhtStateSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DhtStateSnapshot
impl Debug for DhtStateSnapshot
Source§impl<'de> Deserialize<'de> for DhtStateSnapshot
impl<'de> Deserialize<'de> for DhtStateSnapshot
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>,
Auto Trait Implementations§
impl Freeze for DhtStateSnapshot
impl RefUnwindSafe for DhtStateSnapshot
impl Send for DhtStateSnapshot
impl Sync for DhtStateSnapshot
impl Unpin for DhtStateSnapshot
impl UnsafeUnpin for DhtStateSnapshot
impl UnwindSafe for DhtStateSnapshot
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more