Struct embedded_redis::subscription::Subscription
source · 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> !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