pub struct SubSocket<T: Transport<A>, A: Address> { /* private fields */ }Expand description
A subscriber socket. This socket implements Stream and yields incoming PubMessages.
Implementations§
Source§impl<T> SubSocket<T, SocketAddr>
impl<T> SubSocket<T, SocketAddr>
Sourcepub async fn connect(
&mut self,
endpoint: impl ToSocketAddrs,
) -> Result<(), SubError>
pub async fn connect( &mut self, endpoint: impl ToSocketAddrs, ) -> Result<(), SubError>
Connects to the given endpoint asynchronously.
Sourcepub fn try_connect(
&mut self,
endpoint: impl Into<String>,
) -> Result<(), SubError>
pub fn try_connect( &mut self, endpoint: impl Into<String>, ) -> Result<(), SubError>
Attempts to connect to the given endpoint immediately.
Sourcepub async fn disconnect(
&mut self,
endpoint: impl ToSocketAddrs,
) -> Result<(), SubError>
pub async fn disconnect( &mut self, endpoint: impl ToSocketAddrs, ) -> Result<(), SubError>
Disconnects from the given endpoint asynchronously.
Source§impl<T> SubSocket<T, PathBuf>
impl<T> SubSocket<T, PathBuf>
Sourcepub async fn connect_path(
&mut self,
path: impl Into<PathBuf>,
) -> Result<(), SubError>
pub async fn connect_path( &mut self, path: impl Into<PathBuf>, ) -> Result<(), SubError>
Connects to the given path asynchronously.
Sourcepub fn try_connect_path(
&mut self,
path: impl Into<PathBuf>,
) -> Result<(), SubError>
pub fn try_connect_path( &mut self, path: impl Into<PathBuf>, ) -> Result<(), SubError>
Attempts to connect to the given path immediately.
Source§impl<T, A> SubSocket<T, A>
impl<T, A> SubSocket<T, A>
Sourcepub fn new(transport: T) -> Self
pub fn new(transport: T) -> Self
Creates a new subscriber socket with the default SubOptions.
Sourcepub fn with_options(transport: T, options: SubOptions) -> Self
pub fn with_options(transport: T, options: SubOptions) -> Self
Creates a new subscriber socket with the given transport and options.
Sourcepub fn with_connection_hook<H>(self, hook: H) -> Selfwhere
H: ConnectionHook<T::Io>,
pub fn with_connection_hook<H>(self, hook: H) -> Selfwhere
H: ConnectionHook<T::Io>,
Sets the connection hook for this socket.
The connection hook is called after connecting to each publisher, before the connection is used for pub/sub communication.
§Panics
Panics if the driver has already been started (i.e., after calling connect).
Sourcepub async fn connect_inner(&mut self, endpoint: A) -> Result<(), SubError>
pub async fn connect_inner(&mut self, endpoint: A) -> Result<(), SubError>
Asynchronously connects to the endpoint.
Sourcepub fn try_connect_inner(&mut self, endpoint: A) -> Result<(), SubError>
pub fn try_connect_inner(&mut self, endpoint: A) -> Result<(), SubError>
Immediately send a connect command to the driver.
Sourcepub async fn disconnect_inner(&mut self, endpoint: A) -> Result<(), SubError>
pub async fn disconnect_inner(&mut self, endpoint: A) -> Result<(), SubError>
Asynchronously disconnects from the endpoint.
Sourcepub fn try_disconnect_inner(&mut self, endpoint: A) -> Result<(), SubError>
pub fn try_disconnect_inner(&mut self, endpoint: A) -> Result<(), SubError>
Immediately send a disconnect command to the driver.
Sourcepub async fn subscribe(
&mut self,
topic: impl Into<String>,
) -> Result<(), SubError>
pub async fn subscribe( &mut self, topic: impl Into<String>, ) -> Result<(), SubError>
Subscribes to the given topic. This will subscribe to all connected publishers. If the topic does not exist on a publisher, this will not return any data. Any publishers that are connected after this call will also be subscribed to.
Sourcepub fn try_subscribe(
&mut self,
topic: impl Into<String>,
) -> Result<(), SubError>
pub fn try_subscribe( &mut self, topic: impl Into<String>, ) -> Result<(), SubError>
Immediately send a subscribe command to the driver.
Sourcepub async fn unsubscribe(
&mut self,
topic: impl Into<String>,
) -> Result<(), SubError>
pub async fn unsubscribe( &mut self, topic: impl Into<String>, ) -> Result<(), SubError>
Unsubscribe from the given topic. This will unsubscribe from all connected publishers.
Trait Implementations§
Source§impl<T: Transport<A> + Unpin, A: Address> Stream for SubSocket<T, A>
impl<T: Transport<A> + Unpin, A: Address> Stream for SubSocket<T, A>
Source§type Item = PubMessage<A>
type Item = PubMessage<A>
Auto Trait Implementations§
impl<T, A> Freeze for SubSocket<T, A>where
T: Freeze,
impl<T, A> !RefUnwindSafe for SubSocket<T, A>
impl<T, A> Send for SubSocket<T, A>
impl<T, A> Sync for SubSocket<T, A>
impl<T, A> Unpin for SubSocket<T, A>
impl<T, A> UnsafeUnpin for SubSocket<T, A>where
T: UnsafeUnpin,
impl<T, A> !UnwindSafe for SubSocket<T, A>
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> 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> SpanExt<T> for T
impl<T> SpanExt<T> for T
fn with_span(self, span: impl IntoSpanExt) -> WithSpan<T>
fn with_current_span(self) -> WithSpan<T>
Source§impl<St> StreamExt for St
impl<St> StreamExt for St
Source§fn next(&mut self) -> Next<'_, Self>where
Self: Unpin,
fn next(&mut self) -> Next<'_, Self>where
Self: Unpin,
None if the
stream is finished. Read moreSource§fn try_next<T, E>(&mut self) -> TryNext<'_, Self>
fn try_next<T, E>(&mut self) -> TryNext<'_, Self>
Source§fn map<T, F>(self, f: F) -> Map<Self, F>
fn map<T, F>(self, f: F) -> Map<Self, F>
Source§fn map_while<T, F>(self, f: F) -> MapWhile<Self, F>
fn map_while<T, F>(self, f: F) -> MapWhile<Self, F>
None. Read moreSource§fn then<F, Fut>(self, f: F) -> Then<Self, Fut, F>
fn then<F, Fut>(self, f: F) -> Then<Self, Fut, F>
Source§fn merge<U>(self, other: U) -> Merge<Self, U>
fn merge<U>(self, other: U) -> Merge<Self, U>
Source§fn filter<F>(self, f: F) -> Filter<Self, F>
fn filter<F>(self, f: F) -> Filter<Self, F>
Source§fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>
fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>
Source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
None. Read moreSource§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
n items of the underlying stream. Read moreSource§fn take_while<F>(self, f: F) -> TakeWhile<Self, F>
fn take_while<F>(self, f: F) -> TakeWhile<Self, F>
true. Read moreSource§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
n first items of the
underlying stream. Read moreSource§fn skip_while<F>(self, f: F) -> SkipWhile<Self, F>
fn skip_while<F>(self, f: F) -> SkipWhile<Self, F>
true. Read moreSource§fn all<F>(&mut self, f: F) -> AllFuture<'_, Self, F>
fn all<F>(&mut self, f: F) -> AllFuture<'_, Self, F>
Source§fn any<F>(&mut self, f: F) -> AnyFuture<'_, Self, F>
fn any<F>(&mut self, f: F) -> AnyFuture<'_, Self, F>
Source§fn chain<U>(self, other: U) -> Chain<Self, U>
fn chain<U>(self, other: U) -> Chain<Self, U>
Source§fn fold<B, F>(self, init: B, f: F) -> FoldFuture<Self, B, F>
fn fold<B, F>(self, init: B, f: F) -> FoldFuture<Self, B, F>
Source§fn collect<T>(
self,
) -> Collect<Self, T, <T as FromStreamPriv<Self::Item>>::InternalCollection>
fn collect<T>( self, ) -> Collect<Self, T, <T as FromStreamPriv<Self::Item>>::InternalCollection>
Source§fn timeout(self, duration: Duration) -> Timeout<Self>where
Self: Sized,
fn timeout(self, duration: Duration) -> Timeout<Self>where
Self: Sized,
time only.Source§fn timeout_repeating(self, interval: Interval) -> TimeoutRepeating<Self>where
Self: Sized,
fn timeout_repeating(self, interval: Interval) -> TimeoutRepeating<Self>where
Self: Sized,
time only.Source§fn throttle(self, duration: Duration) -> Throttle<Self>where
Self: Sized,
fn throttle(self, duration: Duration) -> Throttle<Self>where
Self: Sized,
time only.Source§fn chunks_timeout(
self,
max_size: usize,
duration: Duration,
) -> ChunksTimeout<Self>where
Self: Sized,
fn chunks_timeout(
self,
max_size: usize,
duration: Duration,
) -> ChunksTimeout<Self>where
Self: Sized,
time only.Source§impl<T> StreamExt for T
impl<T> StreamExt for T
Source§fn next(&mut self) -> Next<'_, Self>where
Self: Unpin,
fn next(&mut self) -> Next<'_, Self>where
Self: Unpin,
Source§fn into_future(self) -> StreamFuture<Self>
fn into_future(self) -> StreamFuture<Self>
Source§fn map<T, F>(self, f: F) -> Map<Self, F>
fn map<T, F>(self, f: F) -> Map<Self, F>
Source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
Source§fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>
fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>
Source§fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>
fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>
Source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
Source§fn collect<C>(self) -> Collect<Self, C>
fn collect<C>(self) -> Collect<Self, C>
Source§fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB>
fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB>
Source§fn concat(self) -> Concat<Self>
fn concat(self) -> Concat<Self>
Source§fn count(self) -> Count<Self>where
Self: Sized,
fn count(self) -> Count<Self>where
Self: Sized,
Source§fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>
fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>
Source§fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F>
fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F>
true if any element in stream satisfied a predicate. Read moreSource§fn all<Fut, F>(self, f: F) -> All<Self, Fut, F>
fn all<Fut, F>(self, f: F) -> All<Self, Fut, F>
true if all element in stream satisfied a predicate. Read moreSource§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn flatten_unordered(
self,
limit: impl Into<Option<usize>>,
) -> FlattenUnorderedWithFlowController<Self, ()>
fn flatten_unordered( self, limit: impl Into<Option<usize>>, ) -> FlattenUnorderedWithFlowController<Self, ()>
alloc only.Source§fn flat_map_unordered<U, F>(
self,
limit: impl Into<Option<usize>>,
f: F,
) -> FlatMapUnordered<Self, U, F>
fn flat_map_unordered<U, F>( self, limit: impl Into<Option<usize>>, f: F, ) -> FlatMapUnordered<Self, U, F>
alloc only.StreamExt::map but flattens nested Streams
and polls them concurrently, yielding items in any order, as they made
available. Read moreSource§fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>
fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>
StreamExt::fold that holds internal state
and produces a new stream. Read moreSource§fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>
fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>
true. Read moreSource§fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>
fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>
true. Read moreSource§fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>
fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>
Source§fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>
fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>
Source§fn for_each_concurrent<Fut, F>(
self,
limit: impl Into<Option<usize>>,
f: F,
) -> ForEachConcurrent<Self, Fut, F>
fn for_each_concurrent<Fut, F>( self, limit: impl Into<Option<usize>>, f: F, ) -> ForEachConcurrent<Self, Fut, F>
alloc only.Source§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
n items of the underlying stream. Read moreSource§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
n items of the underlying stream. Read moreSource§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
std only.Source§fn boxed<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a>>
alloc only.Source§fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a>>where
Self: Sized + 'a,
alloc only.Source§fn buffered(self, n: usize) -> Buffered<Self>
fn buffered(self, n: usize) -> Buffered<Self>
alloc only.Source§fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
alloc only.Source§fn zip<St>(self, other: St) -> Zip<Self, St>
fn zip<St>(self, other: St) -> Zip<Self, St>
Source§fn peekable(self) -> Peekable<Self>where
Self: Sized,
fn peekable(self) -> Peekable<Self>where
Self: Sized,
peek method. Read moreSource§fn chunks(self, capacity: usize) -> Chunks<Self>where
Self: Sized,
fn chunks(self, capacity: usize) -> Chunks<Self>where
Self: Sized,
alloc only.Source§fn ready_chunks(self, capacity: usize) -> ReadyChunks<Self>where
Self: Sized,
fn ready_chunks(self, capacity: usize) -> ReadyChunks<Self>where
Self: Sized,
alloc only.Source§fn forward<S>(self, sink: S) -> Forward<Self, S>
fn forward<S>(self, sink: S) -> Forward<Self, S>
sink only.Source§fn split<Item>(self) -> (SplitSink<Self, Item>, SplitStream<Self>)
fn split<Item>(self) -> (SplitSink<Self, Item>, SplitStream<Self>)
sink and alloc only.Source§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§fn left_stream<B>(self) -> Either<Self, B>
fn left_stream<B>(self) -> Either<Self, B>
Source§fn right_stream<B>(self) -> Either<B, Self>
fn right_stream<B>(self) -> Either<B, Self>
Source§fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>where
Self: Unpin,
fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>where
Self: Unpin,
Stream::poll_next on Unpin
stream types.