pub struct SubCore<PeerId> { /* private fields */ }Expand description
Core state for SUB socket behavior.
Implementations§
Source§impl<PeerId> SubCore<PeerId>
impl<PeerId> SubCore<PeerId>
Sourcepub fn with_filter_inbound(self, filter_inbound: bool) -> Self
pub fn with_filter_inbound(self, filter_inbound: bool) -> Self
Controls whether inbound messages are filtered against local subscriptions.
Sourcepub fn add_peer(&mut self, peer: PeerId) -> Vec<PatternAction<PeerId>>
pub fn add_peer(&mut self, peer: PeerId) -> Vec<PatternAction<PeerId>>
Adds a peer and replays local subscriptions to it.
Sourcepub fn remove_peer(&mut self, peer: PeerId)
pub fn remove_peer(&mut self, peer: PeerId)
Removes a peer from the active SUB peer set.
Sourcepub fn subscribe(
&mut self,
topic: &Bytes,
) -> Result<Vec<PatternAction<PeerId>>, ProtocolError>
pub fn subscribe( &mut self, topic: &Bytes, ) -> Result<Vec<PatternAction<PeerId>>, ProtocolError>
Registers a local subscription and fans it out to connected peers.
§Errors
This method currently does not return an error.
Sourcepub fn cancel(
&mut self,
topic: &Bytes,
) -> Result<Vec<PatternAction<PeerId>>, ProtocolError>
pub fn cancel( &mut self, topic: &Bytes, ) -> Result<Vec<PatternAction<PeerId>>, ProtocolError>
Removes a local subscription and fans the cancel out to connected peers.
§Errors
Returns ProtocolError::UnknownSubscription when topic is not
currently subscribed.
Sourcepub fn on_peer_event(
&mut self,
peer: PeerId,
event: PeerEvent,
) -> Result<Vec<PatternAction<PeerId>>, ProtocolError>
pub fn on_peer_event( &mut self, peer: PeerId, event: PeerEvent, ) -> Result<Vec<PatternAction<PeerId>>, ProtocolError>
Handles inbound peer events for a SUB socket.
§Errors
Returns ProtocolError::EmptyMessage when an inbound message has no
frames.
Trait Implementations§
Auto Trait Implementations§
impl<PeerId> Freeze for SubCore<PeerId>
impl<PeerId> RefUnwindSafe for SubCore<PeerId>where
PeerId: RefUnwindSafe,
impl<PeerId> Send for SubCore<PeerId>where
PeerId: Send,
impl<PeerId> Sync for SubCore<PeerId>where
PeerId: Sync,
impl<PeerId> Unpin for SubCore<PeerId>where
PeerId: Unpin,
impl<PeerId> UnsafeUnpin for SubCore<PeerId>
impl<PeerId> UnwindSafe for SubCore<PeerId>where
PeerId: UnwindSafe,
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