| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{selfrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#}; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().; |
| 4 | |
| 5 | use futures_channelrust-analyzer cargo futures-channel 0.3.34 crate/::mpscrust-analyzer cargo futures-channel 0.3.34 mpsc/; |
| 6 | use futures_corerust-analyzer cargo futures-core 0.3.34 crate/::futurerust-analyzer cargo futures-core 0.3.34 future/::BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#; |
| 7 | use futures_corerust-analyzer cargo futures-core 0.3.34 crate/::streamrust-analyzer cargo futures-core 0.3.34 stream/::{BoxStreamrust-analyzer cargo futures-core 0.3.34 stream/BoxStream#, Streamrust-analyzer cargo futures-core 0.3.34 stream/Stream#}; |
| 8 | use futures_utilrust-analyzer cargo futures-util 0.3.34 crate/::{FutureExtrust-analyzer cargo futures-util 0.3.34 future/future/FutureExt#, StreamExtrust-analyzer cargo futures-util 0.3.34 stream/stream/StreamExt#, TryFutureExtrust-analyzer cargo futures-util 0.3.34 future/try_future/TryFutureExt#, TryStreamExtrust-analyzer cargo futures-util 0.3.34 stream/try_stream/TryStreamExt#}; |
| 9 | use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::acquirerust-analyzer cargo sqlx-core 0.8.3 acquire/::Acquirerust-analyzer cargo sqlx-core 0.8.3 acquire/Acquire#; |
| 10 | use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/::Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#; |
| 11 | use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::Eitherrust-analyzer cargo either 1.18.0 Either#; |
| 12 | |
| 13 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::describerust-analyzer cargo sqlx-core 0.8.3 describe/::Describerust-analyzer cargo sqlx-core 0.8.3 describe/Describe#; |
| 14 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::errorrust-analyzer cargo sqlx-postgres 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#; |
| 15 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::executorrust-analyzer cargo sqlx-core 0.8.3 executor/::{Executerust-analyzer cargo sqlx-core 0.8.3 executor/Execute#, Executorrust-analyzer cargo sqlx-core 0.8.3 executor/Executor#}; |
| 16 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::messagerust-analyzer cargo sqlx-postgres 0.8.3 message/::{BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#, Notificationrust-analyzer cargo sqlx-postgres 0.8.3 message/notification/Notification#}; |
| 17 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::poolrust-analyzer cargo sqlx-core 0.8.3 pool/::PoolOptionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#; |
| 18 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::poolrust-analyzer cargo sqlx-core 0.8.3 pool/::{Poolrust-analyzer cargo sqlx-core 0.8.3 pool/Pool#, PoolConnectionrust-analyzer cargo sqlx-core 0.8.3 pool/connection/PoolConnection#}; |
| 19 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::{PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#, PgQueryResultrust-analyzer cargo sqlx-postgres 0.8.3 query_result/PgQueryResult#, PgRowrust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#, PgStatementrust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatement#, PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#}; |
| 20 | |
| 21 | /// A stream of asynchronous notifications from Postgres. |
| 22 | /// |
| 23 | /// This listener will auto-reconnect. If the active |
| 24 | /// connection being used ever dies, this listener will detect that event, create a |
| 25 | /// new connection, will re-subscribe to all of the originally specified channels, and will resume |
| 26 | /// operations as normal. |
| 27 | pub struct PgListenerrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener# { |
| 28 | poolrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#pool.: Poolrust-analyzer cargo sqlx-core 0.8.3 pool/Pool#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>, |
| 29 | connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#connection.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<PoolConnectionrust-analyzer cargo sqlx-core 0.8.3 pool/connection/PoolConnection#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>>, |
| 30 | buffer_rxrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#buffer_rx.: mpscrust-analyzer cargo futures-channel 0.3.34 mpsc/::UnboundedReceiverrust-analyzer cargo futures-channel 0.3.34 mpsc/UnboundedReceiver#<Notificationrust-analyzer cargo sqlx-postgres 0.8.3 message/notification/Notification#>, |
| 31 | buffer_txrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#buffer_tx.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<mpscrust-analyzer cargo futures-channel 0.3.34 mpsc/::UnboundedSenderrust-analyzer cargo futures-channel 0.3.34 mpsc/UnboundedSender#<Notificationrust-analyzer cargo sqlx-postgres 0.8.3 message/notification/Notification#>>, |
| 32 | channelsrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#channels.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 33 | ignore_close_eventrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#ignore_close_event.: bool, |
| 34 | eager_reconnectrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#eager_reconnect.: bool, |
| 35 | } |
| 36 | |
| 37 | /// An asynchronous notification from Postgres. |
| 38 | pub struct PgNotificationrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgNotification#(Notificationrust-analyzer cargo sqlx-postgres 0.8.3 message/notification/Notification#); |
| 39 | |
| 40 | impl PgListenerrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener# { |
| 41 | pub async fn connectrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connect().(url: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener], Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 42 | // Create a pool of 1 without timeouts (as they don't apply here) |
| 43 | // We only use the pool to handle re-connections |
| 44 | let pool = PoolOptionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/PoolOptions#::<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>::newrust-analyzer cargo sqlx-core 0.8.3 pool/options/impl#[`PoolOptions<DB>`]new().() |
| 45 | .max_connectionsrust-analyzer cargo sqlx-core 0.8.3 pool/options/impl#[`PoolOptions<DB>`]max_connections().(1) |
| 46 | .max_lifetimerust-analyzer cargo sqlx-core 0.8.3 pool/options/impl#[`PoolOptions<DB>`]max_lifetime().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) |
| 47 | .idle_timeoutrust-analyzer cargo sqlx-core 0.8.3 pool/options/impl#[`PoolOptions<DB>`]idle_timeout().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) |
| 48 | .connectrust-analyzer cargo sqlx-core 0.8.3 pool/options/impl#[`PoolOptions<DB>`]connect().(url) |
| 49 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 50 | |
| 51 | let mut this = Selfrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]::connect_withrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connect_with().(&pool).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 52 | // We don't need to handle close events |
| 53 | this.ignore_close_eventrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#ignore_close_event. = true; |
| 54 | |
| 55 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(this) |
| 56 | } |
| 57 | |
| 58 | pub async fn connect_withrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connect_with().(pool: &Poolrust-analyzer cargo sqlx-core 0.8.3 pool/Pool#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener], Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 59 | // Pull out an initial connection |
| 60 | let mut connection = pool.acquirerust-analyzer cargo sqlx-core 0.8.3 pool/impl#[`Pool<DB>`]acquire().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 61 | |
| 62 | // Setup a notification buffer |
| 63 | let (sender, receiver) = mpscrust-analyzer cargo futures-channel 0.3.34 mpsc/::unboundedrust-analyzer cargo futures-channel 0.3.34 mpsc/unbounded().(); |
| 64 | connection.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..notificationsrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/PgStream#notifications. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(sender); |
| 65 | |
| 66 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener] { |
| 67 | poolrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#pool.: pool.clonerust-analyzer cargo sqlx-core 0.8.3 pool/impl#[`Pool<DB>`][Clone]clone().(), |
| 68 | connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#connection.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(connection), |
| 69 | buffer_rxrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#buffer_rx.: receiver, |
| 70 | buffer_txrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#buffer_tx.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 71 | channelsrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#channels.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 72 | ignore_close_eventrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#ignore_close_event.: false, |
| 73 | eager_reconnectrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#eager_reconnect.: true, |
| 74 | }) |
| 75 | } |
| 76 | |
| 77 | /// Set whether or not to ignore [`Pool::close_event()`]. Defaults to `false`. |
| 78 | /// |
| 79 | /// By default, when [`Pool::close()`] is called on the pool this listener is using |
| 80 | /// while [`Self::recv()`] or [`Self::try_recv()`] are waiting for a message, the wait is |
| 81 | /// cancelled and `Err(PoolClosed)` is returned. |
| 82 | /// |
| 83 | /// This is because `Pool::close()` will wait until _all_ connections are returned and closed, |
| 84 | /// including the one being used by this listener. |
| 85 | /// |
| 86 | /// Otherwise, `pool.close().await` would have to wait until `PgListener` encountered a |
| 87 | /// need to acquire a new connection (timeout, error, etc.) and dropped the one it was |
| 88 | /// currently holding, at which point `.recv()` or `.try_recv()` would return `Err(PoolClosed)` |
| 89 | /// on the attempt to acquire a new connection anyway. |
| 90 | /// |
| 91 | /// However, if you want `PgListener` to ignore the close event and continue waiting for a |
| 92 | /// message as long as it can, set this to `true`. |
| 93 | /// |
| 94 | /// Does nothing if this was constructed with [`PgListener::connect()`], as that creates an |
| 95 | /// internal pool just for the new instance of `PgListener` which cannot be closed manually. |
| 96 | pub fn ignore_pool_close_eventrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]ignore_pool_close_event().(&mut self, val: bool) { |
| 97 | self.ignore_close_eventrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#ignore_close_event. = val; |
| 98 | } |
| 99 | |
| 100 | /// Set whether a lost connection in `try_recv()` should be re-established before it returns |
| 101 | /// `Ok(None)`, or on the next call to `try_recv()`. |
| 102 | /// |
| 103 | /// By default, this is `true` and the connection is re-established before returning `Ok(None)`. |
| 104 | /// |
| 105 | /// If this is set to `false` then notifications will continue to be lost until the next call |
| 106 | /// to `try_recv()`. If your recovery logic uses a different database connection then |
| 107 | /// notifications that occur after it completes may be lost without any way to tell that they |
| 108 | /// have been. |
| 109 | pub fn eager_reconnectrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]eager_reconnect().(&mut self, val: bool) { |
| 110 | self.eager_reconnectrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#eager_reconnect. = val; |
| 111 | } |
| 112 | |
| 113 | /// Starts listening for notifications on a channel. |
| 114 | /// The channel name is quoted here to ensure case sensitivity. |
| 115 | pub async fn listenrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]listen().(&mut self, channel: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 116 | self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connection().() |
| 117 | .await?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 118 | .executerust-analyzer cargo sqlx-core 0.8.3 executor/Executor#execute().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(r#"LISTEN "{}""#, identrust-analyzer cargo sqlx-postgres 0.8.3 listener/ident().(channel))) |
| 119 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 120 | |
| 121 | self.channelsrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#channels..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(channel.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 122 | |
| 123 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 124 | } |
| 125 | |
| 126 | /// Starts listening for notifications on all channels. |
| 127 | pub async fn listen_allrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]listen_all().( |
| 128 | &mut self, |
| 129 | channels: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = &str>, |
| 130 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 131 | let beg = self.channelsrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#channels..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(); |
| 132 | self.channelsrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#channels..extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(channels.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 133 | |
| 134 | let query = build_listen_all_queryrust-analyzer cargo sqlx-postgres 0.8.3 listener/build_listen_all_query().(&self.channelsrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#channels.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().beg..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().); |
| 135 | self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connection().().await?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..executerust-analyzer cargo sqlx-core 0.8.3 executor/Executor#execute().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().query).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 136 | |
| 137 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 138 | } |
| 139 | |
| 140 | /// Stops listening for notifications on a channel. |
| 141 | /// The channel name is quoted here to ensure case sensitivity. |
| 142 | pub async fn unlistenrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]unlisten().(&mut self, channel: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 143 | // use RAW connection and do NOT re-connect automatically, since this is not required for |
| 144 | // UNLISTEN (we've disconnected anyways) |
| 145 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(connection) = self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#connection..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().() { |
| 146 | connection |
| 147 | .executerust-analyzer cargo sqlx-core 0.8.3 executor/Executor#execute().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(r#"UNLISTEN "{}""#, identrust-analyzer cargo sqlx-postgres 0.8.3 listener/ident().(channel))) |
| 148 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 149 | } |
| 150 | |
| 151 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pos) = self.channelsrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#channels..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]position().(|s| s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().channel) { |
| 152 | self.channelsrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#channels..removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]remove().(pos); |
| 153 | } |
| 154 | |
| 155 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 156 | } |
| 157 | |
| 158 | /// Stops listening for notifications on all channels. |
| 159 | pub async fn unlisten_allrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]unlisten_all().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 160 | // use RAW connection and do NOT re-connect automatically, since this is not required for |
| 161 | // UNLISTEN (we've disconnected anyways) |
| 162 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(connection) = self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#connection..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().() { |
| 163 | connection.executerust-analyzer cargo sqlx-core 0.8.3 executor/Executor#execute().("UNLISTEN *").rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 164 | } |
| 165 | |
| 166 | self.channelsrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#channels..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().(); |
| 167 | |
| 168 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 169 | } |
| 170 | |
| 171 | #[inline] |
| 172 | async fn connect_if_neededrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connect_if_needed().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 173 | if self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#connection..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 174 | let mut connection = self.poolrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#pool..acquirerust-analyzer cargo sqlx-core 0.8.3 pool/impl#[`Pool<DB>`]acquire().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 175 | connection.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..notificationsrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/PgStream#notifications. = self.buffer_txrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#buffer_tx..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().(); |
| 176 | |
| 177 | connection |
| 178 | .executerust-analyzer cargo sqlx-core 0.8.3 executor/Executor#execute().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().build_listen_all_queryrust-analyzer cargo sqlx-postgres 0.8.3 listener/build_listen_all_query().(&self.channelsrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#channels.)) |
| 179 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 180 | |
| 181 | self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#connection. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(connection); |
| 182 | } |
| 183 | |
| 184 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 185 | } |
| 186 | |
| 187 | #[inline] |
| 188 | async fn connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connection().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&mut PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 189 | // Ensure we have an active connection to work with. |
| 190 | self.connect_if_neededrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connect_if_needed().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 191 | |
| 192 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#connection..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()) |
| 193 | } |
| 194 | |
| 195 | /// Receives the next notification available from any of the subscribed channels. |
| 196 | /// |
| 197 | /// If the connection to PostgreSQL is lost, it is automatically reconnected on the next |
| 198 | /// call to `recv()`, and should be entirely transparent (as long as it was just an |
| 199 | /// intermittent network failure or long-lived connection reaper). |
| 200 | /// |
| 201 | /// As notifications are transient, any received while the connection was lost, will not |
| 202 | /// be returned. If you'd prefer the reconnection to be explicit and have a chance to |
| 203 | /// do something before, please see [`try_recv`](Self::try_recv). |
| 204 | /// |
| 205 | /// # Example |
| 206 | /// |
| 207 | /// ```rust,no_run |
| 208 | /// # use sqlx::postgres::PgListener; |
| 209 | /// # |
| 210 | /// # sqlx::__rt::test_block_on(async move { |
| 211 | /// let mut listener = PgListener::connect("postgres:// ...").await?; |
| 212 | /// loop { |
| 213 | /// // ask for next notification, re-connecting (transparently) if needed |
| 214 | /// let notification = listener.recv().await?; |
| 215 | /// |
| 216 | /// // handle notification, do something interesting |
| 217 | /// } |
| 218 | /// # Result::<(), sqlx::Error>::Ok(()) |
| 219 | /// # }).unwrap(); |
| 220 | /// ``` |
| 221 | pub async fn recvrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]recv().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgNotificationrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgNotification#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 222 | loop { |
| 223 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(notification) = self.try_recvrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]try_recv().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 224 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(notification); |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | /// Receives the next notification available from any of the subscribed channels. |
| 230 | /// |
| 231 | /// If the connection to PostgreSQL is lost, `None` is returned, and the connection is |
| 232 | /// reconnected either immediately, or on the next call to `try_recv()`, depending on |
| 233 | /// the value of [`eager_reconnect`]. |
| 234 | /// |
| 235 | /// # Example |
| 236 | /// |
| 237 | /// ```rust,no_run |
| 238 | /// # use sqlx::postgres::PgListener; |
| 239 | /// # |
| 240 | /// # sqlx::__rt::test_block_on(async move { |
| 241 | /// # let mut listener = PgListener::connect("postgres:// ...").await?; |
| 242 | /// loop { |
| 243 | /// // start handling notifications, connecting if needed |
| 244 | /// while let Some(notification) = listener.try_recv().await? { |
| 245 | /// // handle notification |
| 246 | /// } |
| 247 | /// |
| 248 | /// // connection lost, do something interesting |
| 249 | /// } |
| 250 | /// # Result::<(), sqlx::Error>::Ok(()) |
| 251 | /// # }).unwrap(); |
| 252 | /// ``` |
| 253 | /// |
| 254 | /// [`eager_reconnect`]: PgListener::eager_reconnect |
| 255 | pub async fn try_recvrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]try_recv().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<PgNotificationrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgNotification#>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 256 | // Flush the buffer first, if anything |
| 257 | // This would only fill up if this listener is used as a connection |
| 258 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(notification) = self.next_bufferedrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]next_buffered().() { |
| 259 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(notification)); |
| 260 | } |
| 261 | |
| 262 | // Fetch our `CloseEvent` listener, if applicable. |
| 263 | let mut close_event = (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.ignore_close_eventrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#ignore_close_event.).thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then().(|| self.poolrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#pool..close_eventrust-analyzer cargo sqlx-core 0.8.3 pool/impl#[`Pool<DB>`]close_event().()); |
| 264 | |
| 265 | loop { |
| 266 | let next_message = self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connection().().await?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..recv_uncheckedrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/impl#[PgStream]recv_unchecked().(); |
| 267 | |
| 268 | let res = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref mut close_event) = close_event { |
| 269 | // cancels the wait and returns `Err(PoolClosed)` if the pool is closed |
| 270 | // before `next_message` returns, or if the pool was already closed |
| 271 | close_event.do_untilrust-analyzer cargo sqlx-core 0.8.3 pool/impl#[CloseEvent]do_until().(next_message).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 272 | } else { |
| 273 | next_message.rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll(). |
| 274 | }; |
| 275 | |
| 276 | let message = match res { |
| 277 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(message) => message, |
| 278 | |
| 279 | // The connection is dead, ensure that it is dropped, |
| 280 | // update self state, and loop to try again. |
| 281 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Iorust-analyzer cargo sqlx-core 0.8.3 error/Error#Io#(err)) |
| 282 | if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!( |
| 283 | err.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().(), |
| 284 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::ConnectionAbortedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#ConnectionAborted# | |
| 285 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::UnexpectedEofrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#UnexpectedEof# | |
| 286 | // see ERRORS section in tcp(7) man page (https://man7.org/linux/man-pages/man7/tcp.7.html) |
| 287 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::TimedOutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#TimedOut# | |
| 288 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::BrokenPiperust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#BrokenPipe# |
| 289 | ) => |
| 290 | { |
| 291 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mut conn) = self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#connection..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() { |
| 292 | self.buffer_txrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#buffer_tx. = conn.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..notificationsrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/PgStream#notifications..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().(); |
| 293 | // Close the connection in a background task, so we can continue. |
| 294 | conn.close_on_droprust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`PoolConnection<DB>`]close_on_drop().(); |
| 295 | } |
| 296 | |
| 297 | if self.eager_reconnectrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#eager_reconnect. { |
| 298 | self.connect_if_neededrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connect_if_needed().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 299 | } |
| 300 | |
| 301 | // lost connection |
| 302 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 303 | } |
| 304 | |
| 305 | // Forward other errors |
| 306 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) => { |
| 307 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error); |
| 308 | } |
| 309 | }; |
| 310 | |
| 311 | match message.formatrust-analyzer cargo sqlx-postgres 0.8.3 message/ReceivedMessage#format. { |
| 312 | // We've received an async notification, return it. |
| 313 | BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::NotificationResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#NotificationResponse# => { |
| 314 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PgNotificationrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgNotification#(message.decoderust-analyzer cargo sqlx-postgres 0.8.3 message/impl#[ReceivedMessage]decode().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().))); |
| 315 | } |
| 316 | |
| 317 | // Mark the connection as ready for another query |
| 318 | BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::ReadyForQueryrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ReadyForQuery# => { |
| 319 | self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connection().().await?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..pending_ready_for_query_countrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#pending_ready_for_query_count. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1; |
| 320 | } |
| 321 | |
| 322 | // Ignore unexpected messages |
| 323 | _ => {} |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | /// Receives the next notification that already exists in the connection buffer, if any. |
| 329 | /// |
| 330 | /// This is similar to `try_recv`, except it will not wait if the connection has not yet received a notification. |
| 331 | /// |
| 332 | /// This is helpful if you want to retrieve all buffered notifications and process them in batches. |
| 333 | pub fn next_bufferedrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]next_buffered().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<PgNotificationrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgNotification#> { |
| 334 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(notification)) = self.buffer_rxrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#buffer_rx..try_nextrust-analyzer cargo futures-channel 0.3.34 mpsc/impl#[`UnboundedReceiver<T>`]try_next().() { |
| 335 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PgNotificationrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgNotification#(notification)) |
| 336 | } else { |
| 337 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | /// Consume this listener, returning a `Stream` of notifications. |
| 342 | /// |
| 343 | /// The backing connection will be automatically reconnected should it be lost. |
| 344 | /// |
| 345 | /// This has the same potential drawbacks as [`recv`](PgListener::recv). |
| 346 | /// |
| 347 | pub fn into_streamrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]into_stream().(mut self) -> impl Streamrust-analyzer cargo futures-core 0.3.34 stream/Stream#<Itemrust-analyzer cargo futures-core 0.3.34 stream/Stream#Item# = Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgNotificationrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgNotification#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin# { |
| 348 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::pinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]pin().(try_streamrust-analyzer cargo sqlx-core 0.8.3 ext/async_stream/try_stream!! { |
| 349 | loop { |
| 350 | r#yieldrust-analyzer cargo sqlx-postgres 0.8.3 listener/`r#yield`!!(self.recvrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]recv().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 351 | } |
| 352 | }) |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | impl Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for PgListenerrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener# { |
| 357 | fn droprust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener][Drop]drop().(&mut self) { |
| 358 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mut conn) = self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener#connection..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() { |
| 359 | let fut = async move { |
| 360 | let _ = conn.executerust-analyzer cargo sqlx-core 0.8.3 executor/Executor#execute().("UNLISTEN *").rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().; |
| 361 | |
| 362 | // inline the drop handler from `PoolConnection` so it doesn't try to spawn another task |
| 363 | // otherwise, it may trigger a panic if this task is dropped because the runtime is going away: |
| 364 | // https://github.com/launchbadge/sqlx/issues/1389 |
| 365 | conn.return_to_poolrust-analyzer cargo sqlx-core 0.8.3 pool/connection/impl#[`PoolConnection<DB>`]return_to_pool().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().; |
| 366 | }; |
| 367 | |
| 368 | // Unregister any listeners before returning the connection to the pool. |
| 369 | craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::rtrust-analyzer cargo sqlx-core 0.8.3 rt/::spawnrust-analyzer cargo sqlx-core 0.8.3 rt/spawn().(fut); |
| 370 | } |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | impl<'c> Acquirerust-analyzer cargo sqlx-core 0.8.3 acquire/Acquire#<'c> for &'c mut PgListenerrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener# { |
| 375 | type Databaserust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Acquire<'c>`]Database# = Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#; |
| 376 | type Connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Acquire<'c>`]Connection# = &'c mut PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#; |
| 377 | |
| 378 | fn acquirerust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Acquire<'c>`]acquire().(self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'c, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Acquire<'c>`]::Connectionrust-analyzer cargo sqlx-core 0.8.3 acquire/Acquire#Connection#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> { |
| 379 | self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connection().().boxedrust-analyzer cargo futures-util 0.3.34 future/future/FutureExt#boxed().() |
| 380 | } |
| 381 | |
| 382 | fn beginrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Acquire<'c>`]begin().(self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'c, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#<'c, Selfrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Acquire<'c>`]::Databaserust-analyzer cargo sqlx-core 0.8.3 acquire/Acquire#Database#>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> { |
| 383 | self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connection().().and_thenrust-analyzer cargo futures-util 0.3.34 future/try_future/TryFutureExt#and_then().(|c| c.beginrust-analyzer cargo sqlx-postgres 0.8.3 impl#[`&'c mut PgConnection`][`Acquire<'c>`]begin().()).boxedrust-analyzer cargo futures-util 0.3.34 future/future/FutureExt#boxed().() |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | impl<'c> Executorrust-analyzer cargo sqlx-core 0.8.3 executor/Executor#<'c> for &'c mut PgListenerrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener# { |
| 388 | type Databaserust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Executor<'c>`]Database# = Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#; |
| 389 | |
| 390 | fn fetch_manyrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Executor<'c>`]fetch_many().<'e, 'q, E>( |
| 391 | self, |
| 392 | query: E, |
| 393 | ) -> BoxStreamrust-analyzer cargo futures-core 0.3.34 stream/BoxStream#<'e, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Eitherrust-analyzer cargo either 1.18.0 Either#<PgQueryResultrust-analyzer cargo sqlx-postgres 0.8.3 query_result/PgQueryResult#, PgRowrust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> |
| 394 | where |
| 395 | 'c: 'e, |
| 396 | E: Executerust-analyzer cargo sqlx-core 0.8.3 executor/Execute#<'q, Selfrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Executor<'c>`]::Databaserust-analyzer cargo sqlx-core 0.8.3 executor/Executor#Database#>, |
| 397 | 'q: 'e, |
| 398 | E: 'q, |
| 399 | { |
| 400 | futures_utilrust-analyzer cargo futures-util 0.3.34 crate/::streamrust-analyzer cargo futures-util 0.3.34 stream/::oncerust-analyzer cargo futures-util 0.3.34 stream/once/once().(async move { |
| 401 | // need some basic type annotation to help the compiler a bit |
| 402 | let res: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<_, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> = Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connection().().await?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..fetch_manyrust-analyzer cargo sqlx-postgres 0.8.3 connection/executor/impl#[`&'c mut PgConnection`][`Executor<'c>`]fetch_many().(query)); |
| 403 | res |
| 404 | }) |
| 405 | .try_flattenrust-analyzer cargo futures-util 0.3.34 stream/try_stream/TryStreamExt#try_flatten().() |
| 406 | .boxedrust-analyzer cargo futures-util 0.3.34 stream/stream/StreamExt#boxed().() |
| 407 | } |
| 408 | |
| 409 | fn fetch_optionalrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Executor<'c>`]fetch_optional().<'e, 'q, E>(self, query: E) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'e, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<PgRowrust-analyzer cargo sqlx-postgres 0.8.3 row/PgRow#>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> |
| 410 | where |
| 411 | 'c: 'e, |
| 412 | E: Executerust-analyzer cargo sqlx-core 0.8.3 executor/Execute#<'q, Selfrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Executor<'c>`]::Databaserust-analyzer cargo sqlx-core 0.8.3 executor/Executor#Database#>, |
| 413 | 'q: 'e, |
| 414 | E: 'q, |
| 415 | { |
| 416 | async move { self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connection().().await?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..fetch_optionalrust-analyzer cargo sqlx-postgres 0.8.3 connection/executor/impl#[`&'c mut PgConnection`][`Executor<'c>`]fetch_optional().(query).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll(). }.boxedrust-analyzer cargo futures-util 0.3.34 future/future/FutureExt#boxed().() |
| 417 | } |
| 418 | |
| 419 | fn prepare_withrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Executor<'c>`]prepare_with().<'e, 'q: 'e>( |
| 420 | self, |
| 421 | query: &'q str, |
| 422 | parameters: &'e [PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#], |
| 423 | ) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'e, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgStatementrust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatement#<'q>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> |
| 424 | where |
| 425 | 'c: 'e, |
| 426 | { |
| 427 | async move { |
| 428 | self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connection().() |
| 429 | .await?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 430 | .prepare_withrust-analyzer cargo sqlx-postgres 0.8.3 connection/executor/impl#[`&'c mut PgConnection`][`Executor<'c>`]prepare_with().(query, parameters) |
| 431 | .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll(). |
| 432 | } |
| 433 | .boxedrust-analyzer cargo futures-util 0.3.34 future/future/FutureExt#boxed().() |
| 434 | } |
| 435 | |
| 436 | #[doc(hidden)] |
| 437 | fn describerust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Executor<'c>`]describe().<'e, 'q: 'e>( |
| 438 | self, |
| 439 | query: &'q str, |
| 440 | ) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'e, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Describerust-analyzer cargo sqlx-core 0.8.3 describe/Describe#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[`&'c mut PgListener`][`Executor<'c>`]::Databaserust-analyzer cargo sqlx-core 0.8.3 executor/Executor#Database#>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> |
| 441 | where |
| 442 | 'c: 'e, |
| 443 | { |
| 444 | async move { self.connectionrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener]connection().().await?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..describerust-analyzer cargo sqlx-postgres 0.8.3 connection/executor/impl#[`&'c mut PgConnection`][`Executor<'c>`]describe().(query).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll(). }.boxedrust-analyzer cargo futures-util 0.3.34 future/future/FutureExt#boxed().() |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | impl PgNotificationrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgNotification# { |
| 449 | /// The process ID of the notifying backend process. |
| 450 | #[inline] |
| 451 | pub fn process_idrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgNotification]process_id().(&self) -> u32 { |
| 452 | self.0rust-analyzer cargo sqlx-postgres 0.8.3 listener/PgNotification#0..process_idrust-analyzer cargo sqlx-postgres 0.8.3 message/notification/Notification#process_id. |
| 453 | } |
| 454 | |
| 455 | /// The channel that the notify has been raised on. This can be thought |
| 456 | /// of as the message topic. |
| 457 | #[inline] |
| 458 | pub fn channelrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgNotification]channel().(&self) -> &str { |
| 459 | from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&self.0rust-analyzer cargo sqlx-postgres 0.8.3 listener/PgNotification#0..channelrust-analyzer cargo sqlx-postgres 0.8.3 message/notification/Notification#channel.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 460 | } |
| 461 | |
| 462 | /// The payload of the notification. An empty payload is received as an |
| 463 | /// empty string. |
| 464 | #[inline] |
| 465 | pub fn payloadrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgNotification]payload().(&self) -> &str { |
| 466 | from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&self.0rust-analyzer cargo sqlx-postgres 0.8.3 listener/PgNotification#0..payloadrust-analyzer cargo sqlx-postgres 0.8.3 message/notification/Notification#payload.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | impl Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for PgListenerrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgListener# { |
| 471 | fn fmtrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgListener][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 472 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("PgListener").finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | impl Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for PgNotificationrust-analyzer cargo sqlx-postgres 0.8.3 listener/PgNotification# { |
| 477 | fn fmtrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgNotification][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 478 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("PgNotification") |
| 479 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("process_id", &self.process_idrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgNotification]process_id().()) |
| 480 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("channel", &self.channelrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgNotification]channel().()) |
| 481 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("payload", &self.payloadrust-analyzer cargo sqlx-postgres 0.8.3 listener/impl#[PgNotification]payload().()) |
| 482 | .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | fn identrust-analyzer cargo sqlx-postgres 0.8.3 listener/ident().(mut name: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 487 | // If the input string contains a NUL byte, we should truncate the |
| 488 | // identifier. |
| 489 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(index) = name.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('\0') { |
| 490 | name = &name[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 491 | } |
| 492 | |
| 493 | // Any double quotes must be escaped |
| 494 | name.replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('"', "\"\"") |
| 495 | } |
| 496 | |
| 497 | fn build_listen_all_queryrust-analyzer cargo sqlx-postgres 0.8.3 listener/build_listen_all_query().(channels: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 498 | channels.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#fold().(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(), |mut acc, chan| { |
| 499 | acc.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(r#"LISTEN ""#); |
| 500 | acc.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&identrust-analyzer cargo sqlx-postgres 0.8.3 listener/ident().(chan.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().())); |
| 501 | acc.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(r#"";"#); |
| 502 | acc |
| 503 | }) |
| 504 | } |
| 505 | |
| 506 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 507 | fn test_build_listen_all_query_with_single_channelrust-analyzer cargo sqlx-postgres 0.8.3 listener/test_build_listen_all_query_with_single_channel().() { |
| 508 | let output = build_listen_all_queryrust-analyzer cargo sqlx-postgres 0.8.3 listener/build_listen_all_query().(&["test"]); |
| 509 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(output.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().(), r#"LISTEN "test";"#); |
| 510 | } |
| 511 | |
| 512 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 513 | fn test_build_listen_all_query_with_multiple_channelsrust-analyzer cargo sqlx-postgres 0.8.3 listener/test_build_listen_all_query_with_multiple_channels().() { |
| 514 | let output = build_listen_all_queryrust-analyzer cargo sqlx-postgres 0.8.3 listener/build_listen_all_query().(&["channel.0", "channel.1"]); |
| 515 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(output.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().(), r#"LISTEN "channel.0";LISTEN "channel.1";"#); |
| 516 | } |