pub struct ListenerService { /* private fields */ }Expand description
Service for listening to PostgreSQL NOTIFY messages
Implementations§
Source§impl ListenerService
impl ListenerService
Sourcepub async fn new(pool: &PgPool) -> Result<Self>
pub async fn new(pool: &PgPool) -> Result<Self>
Create a new listener service connected to the database
Sourcepub async fn listen_all(&mut self, channels: &[&str]) -> Result<()>
pub async fn listen_all(&mut self, channels: &[&str]) -> Result<()>
Subscribe to multiple channels
Sourcepub async fn unlisten_all(&mut self) -> Result<()>
pub async fn unlisten_all(&mut self) -> Result<()>
Unsubscribe from all channels
Sourcepub async fn recv(&mut self) -> Result<Notification>
pub async fn recv(&mut self) -> Result<Notification>
Wait for the next notification (blocking)
Sourcepub async fn recv_timeout(
&mut self,
duration: Duration,
) -> Result<Option<Notification>>
pub async fn recv_timeout( &mut self, duration: Duration, ) -> Result<Option<Notification>>
Wait for a notification with timeout
Sourcepub async fn try_recv(&mut self) -> Option<Notification>
pub async fn try_recv(&mut self) -> Option<Notification>
Try to receive without blocking (with zero timeout)
Auto Trait Implementations§
impl Freeze for ListenerService
impl !RefUnwindSafe for ListenerService
impl Send for ListenerService
impl Sync for ListenerService
impl Unpin for ListenerService
impl UnsafeUnpin for ListenerService
impl !UnwindSafe for ListenerService
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> 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