pub struct PeerInfo {
pub id: PeerId,
pub display_name: Option<String>,
pub first_seen: String,
pub last_seen: String,
pub status: PeerStatus,
pub addresses: Vec<Address>,
pub connection_state: ConnectionState,
pub last_successful_sync: Option<String>,
pub connection_attempts: u32,
pub last_error: Option<String>,
}Expand description
Information about a remote peer in the sync network.
Fields§
§id: PeerIdThe peer’s unique identifier
display_name: Option<String>Optional human-readable display name for the peer
first_seen: StringISO timestamp when this peer was first seen
last_seen: StringISO timestamp when this peer was last seen/active
status: PeerStatusCurrent status of the peer
addresses: Vec<Address>Connection addresses for this peer
connection_state: ConnectionStateCurrent connection state
last_successful_sync: Option<String>ISO timestamp of last successful sync
connection_attempts: u32Number of connection attempts
last_error: Option<String>Last connection error if any
Implementations§
Source§impl PeerInfo
impl PeerInfo
Sourcepub fn new_at(
id: impl Into<PeerId>,
display_name: Option<&str>,
timestamp: String,
) -> Self
pub fn new_at( id: impl Into<PeerId>, display_name: Option<&str>, timestamp: String, ) -> Self
Create a new PeerInfo with the given timestamp.
Use instance.now_rfc3339() or transaction.now_rfc3339() to get the timestamp.
Sourcepub fn touch_at(&mut self, timestamp: String)
pub fn touch_at(&mut self, timestamp: String)
Update the last_seen timestamp.
Use instance.now_rfc3339() or transaction.now_rfc3339() to get the timestamp.
Sourcepub fn add_address(&mut self, address: Address)
pub fn add_address(&mut self, address: Address)
Add an address if not already present
Sourcepub fn remove_address(&mut self, address: &Address) -> bool
pub fn remove_address(&mut self, address: &Address) -> bool
Remove a specific address
Sourcepub fn get_addresses(&self, transport_type: impl AsRef<str>) -> Vec<&Address>
pub fn get_addresses(&self, transport_type: impl AsRef<str>) -> Vec<&Address>
Get addresses for a specific transport type
Sourcepub fn get_all_addresses(&self) -> &Vec<Address>
pub fn get_all_addresses(&self) -> &Vec<Address>
Get all addresses
Sourcepub fn has_transport(&self, transport_type: impl AsRef<str>) -> bool
pub fn has_transport(&self, transport_type: impl AsRef<str>) -> bool
Check if peer has any addresses for a transport type
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PeerInfo
impl<'de> Deserialize<'de> for PeerInfo
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>,
impl StructuralPartialEq for PeerInfo
Auto Trait Implementations§
impl Freeze for PeerInfo
impl RefUnwindSafe for PeerInfo
impl Send for PeerInfo
impl Sync for PeerInfo
impl Unpin for PeerInfo
impl UnwindSafe for PeerInfo
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> CompatExt for T
impl<T> CompatExt for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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