pub struct Listener { /* private fields */ }Expand description
A dedicated connection listening on one or more channels, created with
Db::listen. It reconnects automatically if the connection drops
(notifications sent meanwhile are lost).
Implementations§
Source§impl Listener
impl Listener
Sourcepub async fn recv(&mut self) -> Result<Notification, Error>
pub async fn recv(&mut self) -> Result<Notification, Error>
Wait for the next notification.
Sourcepub fn try_recv(&mut self) -> Option<Notification>
pub fn try_recv(&mut self) -> Option<Notification>
The next notification if one has already been received, without waiting.
Sourcepub async fn listen(&mut self, channel: &str) -> Result<(), Error>
pub async fn listen(&mut self, channel: &str) -> Result<(), Error>
Start listening on another channel.
Sourcepub async fn unlisten(&mut self, channel: &str) -> Result<(), Error>
pub async fn unlisten(&mut self, channel: &str) -> Result<(), Error>
Stop listening on a channel.
Sourcepub fn into_stream(
self,
) -> Pin<Box<dyn Stream<Item = Result<Notification, Error>> + Send>>
pub fn into_stream( self, ) -> Pin<Box<dyn Stream<Item = Result<Notification, Error>> + Send>>
Turn into a stream of notifications.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Listener
impl !UnwindSafe for Listener
impl Freeze for Listener
impl Send for Listener
impl Sync for Listener
impl Unpin for Listener
impl UnsafeUnpin for Listener
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
impl<M> InScope<(M, ()), Here> for M
impl<M, Rest, N> InScope<(M, (Rest, N)), Last> for N
impl<X, M, Rest, N, I> InScope<(M, (Rest, N)), There<I>> for X
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> 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