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