pub struct Subscription<'a, N: TcpClientStack, C: Clock, P: Protocol, const L: usize>where
HelloCommand: Command<<P as Protocol>::FrameType>,
<P as Protocol>::FrameType: From<CommandBuilder> + ToPushMessage,{ /* private fields */ }
Expand description
Client for handling subscriptions
L: Number of subscribed topics
Implementations§
Source§impl<'a, N, C, P, const L: usize> Subscription<'a, N, C, P, L>where
N: TcpClientStack,
C: Clock,
P: Protocol,
HelloCommand: Command<<P as Protocol>::FrameType>,
<P as Protocol>::FrameType: From<CommandBuilder> + ToPushMessage,
impl<'a, N, C, P, const L: usize> Subscription<'a, N, C, P, L>where
N: TcpClientStack,
C: Clock,
P: Protocol,
HelloCommand: Command<<P as Protocol>::FrameType>,
<P as Protocol>::FrameType: From<CommandBuilder> + ToPushMessage,
pub fn new(client: Client<'a, N, C, P>, topics: [Bytes; L]) -> Self
Sourcepub fn receive(&mut self) -> Result<Option<Message>, Error>
pub fn receive(&mut self) -> Result<Option<Message>, Error>
Receives a message. Returns None in case no message is pending
Sourcepub fn unsubscribe(self) -> Result<(), Error>
pub fn unsubscribe(self) -> Result<(), Error>
Unsubscribes from all topics and waits for confirmation
If this fails, it’s recommended to clos the connection to avoid subsequent errors caused by invalid state
Trait Implementations§
Source§impl<'a, N: Debug + TcpClientStack, C: Debug + Clock, P: Debug + Protocol, const L: usize> Debug for Subscription<'a, N, C, P, L>where
HelloCommand: Command<<P as Protocol>::FrameType>,
<P as Protocol>::FrameType: From<CommandBuilder> + ToPushMessage,
impl<'a, N: Debug + TcpClientStack, C: Debug + Clock, P: Debug + Protocol, const L: usize> Debug for Subscription<'a, N, C, P, L>where
HelloCommand: Command<<P as Protocol>::FrameType>,
<P as Protocol>::FrameType: From<CommandBuilder> + ToPushMessage,
Source§impl<N, C, P, const L: usize> Drop for Subscription<'_, N, C, P, L>where
N: TcpClientStack,
C: Clock,
P: Protocol,
HelloCommand: Command<<P as Protocol>::FrameType>,
<P as Protocol>::FrameType: From<CommandBuilder> + ToPushMessage,
impl<N, C, P, const L: usize> Drop for Subscription<'_, N, C, P, L>where
N: TcpClientStack,
C: Clock,
P: Protocol,
HelloCommand: Command<<P as Protocol>::FrameType>,
<P as Protocol>::FrameType: From<CommandBuilder> + ToPushMessage,
Auto Trait Implementations§
impl<'a, N, C, P, const L: usize> !Freeze for Subscription<'a, N, C, P, L>
impl<'a, N, C, P, const L: usize> !RefUnwindSafe for Subscription<'a, N, C, P, L>
impl<'a, N, C, P, const L: usize> !Send for Subscription<'a, N, C, P, L>
impl<'a, N, C, P, const L: usize> !Sync for Subscription<'a, N, C, P, L>
impl<'a, N, C, P, const L: usize> Unpin for Subscription<'a, N, C, P, L>
impl<'a, N, C, P, const L: usize> !UnwindSafe for Subscription<'a, N, C, P, L>
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
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>
Converts
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>
Converts
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