pub struct State<PI, R> { /* private fields */ }
Expand description
The topic state maintains the swarm membership and broadcast tree for a particular topic.
Implementations§
Source§impl<PI: PeerIdentity> State<PI, StdRng>
impl<PI: PeerIdentity> State<PI, StdRng>
Source§impl<PI: PeerIdentity, R: Rng> State<PI, R>
impl<PI: PeerIdentity, R: Rng> State<PI, R>
Sourcepub fn with_rng(
me: PI,
me_data: Option<PeerData>,
config: Config,
rng: R,
) -> Self
pub fn with_rng( me: PI, me_data: Option<PeerData>, config: Config, rng: R, ) -> Self
Initialize the local state with a custom random number generator.
Sourcepub fn handle(
&mut self,
event: InEvent<PI>,
now: Instant,
) -> impl Iterator<Item = OutEvent<PI>> + '_
pub fn handle( &mut self, event: InEvent<PI>, now: Instant, ) -> impl Iterator<Item = OutEvent<PI>> + '_
Handle an incoming event.
Returns an iterator of outgoing events that must be processed by the application.
Sourcepub fn stats(&self) -> &Stats
pub fn stats(&self) -> &Stats
Get stats on how many messages were sent and received
TODO: Remove/replace with metrics?
Sourcepub fn gossip_stats(&self) -> &Stats
pub fn gossip_stats(&self) -> &Stats
Get statistics for the gossip broadcast state
TODO: Remove/replace with metrics?
Sourcepub fn has_active_peers(&self) -> bool
pub fn has_active_peers(&self) -> bool
Check if this topic has any active (connected) peers.
Trait Implementations§
Auto Trait Implementations§
impl<PI, R> !Freeze for State<PI, R>
impl<PI, R> RefUnwindSafe for State<PI, R>where
PI: RefUnwindSafe,
R: RefUnwindSafe,
impl<PI, R> Send for State<PI, R>
impl<PI, R> Sync for State<PI, R>
impl<PI, R> Unpin for State<PI, R>
impl<PI, R> UnwindSafe for State<PI, R>where
PI: UnwindSafe,
R: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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