pub struct Subscription<'a, T: Read + Write, 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, T, C, P, const L: usize> Subscription<'a, T, C, P, L>where
T: Read + Write,
C: Clock,
P: Protocol,
HelloCommand: Command<<P as Protocol>::FrameType>,
<P as Protocol>::FrameType: From<CommandBuilder> + ToPushMessage,
impl<'a, T, C, P, const L: usize> Subscription<'a, T, C, P, L>where
T: Read + Write,
C: Clock,
P: Protocol,
HelloCommand: Command<<P as Protocol>::FrameType>,
<P as Protocol>::FrameType: From<CommandBuilder> + ToPushMessage,
pub fn new(client: Client<'a, T, C, P>, topics: [Bytes; L]) -> Self
Sourcepub async fn receive(&mut self) -> Result<Option<Message>, Error>
pub async fn receive(&mut self) -> Result<Option<Message>, Error>
Waits for and receives the next published message.
Sourcepub async fn unsubscribe(self) -> Result<(), Error>
pub async fn unsubscribe(self) -> Result<(), Error>
Unsubscribes from all topics and waits for confirmation
If this fails, the owned connection is dropped to avoid reusing an undefined state.
Trait Implementations§
Source§impl<'a, T: Debug + Read + Write, C: Debug + Clock, P: Debug + Protocol, const L: usize> Debug for Subscription<'a, T, C, P, L>where
HelloCommand: Command<<P as Protocol>::FrameType>,
<P as Protocol>::FrameType: From<CommandBuilder> + ToPushMessage,
impl<'a, T: Debug + Read + Write, C: Debug + Clock, P: Debug + Protocol, const L: usize> Debug for Subscription<'a, T, C, P, L>where
HelloCommand: Command<<P as Protocol>::FrameType>,
<P as Protocol>::FrameType: From<CommandBuilder> + ToPushMessage,
Auto Trait Implementations§
impl<'a, T, C, P, const L: usize> !Freeze for Subscription<'a, T, C, P, L>
impl<'a, T, C, P, const L: usize> !RefUnwindSafe for Subscription<'a, T, C, P, L>
impl<'a, T, C, P, const L: usize> !Send for Subscription<'a, T, C, P, L>
impl<'a, T, C, P, const L: usize> !Sync for Subscription<'a, T, C, P, L>
impl<'a, T, C, P, const L: usize> !Unpin for Subscription<'a, T, C, P, L>
impl<'a, T, C, P, const L: usize> !UnsafeUnpin for Subscription<'a, T, C, P, L>
impl<'a, T, C, P, const L: usize> !UnwindSafe for Subscription<'a, T, 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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