pub struct Client<C = BoxedConnector<RpcService>> { /* private fields */ }
Available on crate feature
rpc
only.Expand description
Iroh gossip client.
Implementations§
Source§impl<C> Client<C>where
C: Connector<RpcService>,
impl<C> Client<C>where
C: Connector<RpcService>,
Sourcepub fn new(rpc: RpcClient<RpcService, C>) -> Self
pub fn new(rpc: RpcClient<RpcService, C>) -> Self
Creates a new gossip client.
Sourcepub async fn subscribe_with_opts(
&self,
topic: TopicId,
opts: SubscribeOpts,
) -> Result<(impl Sink<SubscribeUpdate, Error = Error>, impl Stream<Item = Result<SubscribeResponse>>)>
pub async fn subscribe_with_opts( &self, topic: TopicId, opts: SubscribeOpts, ) -> Result<(impl Sink<SubscribeUpdate, Error = Error>, impl Stream<Item = Result<SubscribeResponse>>)>
Subscribes to a gossip topic.
Returns a sink to send updates to the topic and a stream of responses.
Updates are either Broadcast or BroadcastNeighbors.
Broadcasts are gossiped to the entire swarm, while BroadcastNeighbors are sent to just the immediate neighbors of the node.
Responses are either Gossip or Lagged.
Gossip events contain the actual message content, as well as information about the immediate neighbors of the node.
A Lagged event indicates that the gossip stream has not been consumed quickly enough.
You can adjust the buffer size with the SubscribeOpts::subscription_capacity
option.
Sourcepub async fn subscribe(
&self,
topic: impl Into<TopicId>,
bootstrap: impl IntoIterator<Item = impl Into<NodeId>>,
) -> Result<(impl Sink<SubscribeUpdate, Error = Error>, impl Stream<Item = Result<SubscribeResponse>>)>
pub async fn subscribe( &self, topic: impl Into<TopicId>, bootstrap: impl IntoIterator<Item = impl Into<NodeId>>, ) -> Result<(impl Sink<SubscribeUpdate, Error = Error>, impl Stream<Item = Result<SubscribeResponse>>)>
Subscribes to a gossip topic with default options.
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for Client<C>where
C: Freeze,
impl<C> RefUnwindSafe for Client<C>where
C: RefUnwindSafe,
impl<C> Send for Client<C>where
C: Send,
impl<C> Sync for Client<C>where
C: Sync,
impl<C> Unpin for Client<C>where
C: Unpin,
impl<C> UnwindSafe for Client<C>where
C: 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