pub struct Connection<S, T> { /* private fields */ }Expand description
A connection to a PostgreSQL database.
This is one half of what is returned when a new connection is established. It performs the actual IO with the server, and should generally be spawned off onto an executor to run in the background.
Connection implements Future, and only resolves when the connection is closed, either because a fatal error has
occurred, or because its associated Client has dropped and all outstanding work has completed.
Implementations§
Source§impl<S, T> Connection<S, T>
impl<S, T> Connection<S, T>
Sourcepub fn parameter(&self, name: &str) -> Option<&str>
pub fn parameter(&self, name: &str) -> Option<&str>
Returns the value of a runtime parameter for this connection.
Sourcepub fn poll_message(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<Result<AsyncMessage, Error>>>
pub fn poll_message( &mut self, cx: &mut Context<'_>, ) -> Poll<Option<Result<AsyncMessage, Error>>>
Polls for asynchronous messages from the server.
The server can send notices as well as notifications asynchronously to the client. Applications that wish to
examine those messages should use this method to drive the connection rather than its Future implementation.
Return values of None or Some(Err(_)) are “terminal”; callers should not invoke this method again after
receiving one of those values.
Source§impl<S, T> Connection<S, T>where
S: AsyncRead + AsyncWrite + Unpin + Send + 'static,
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
impl<S, T> Connection<S, T>where
S: AsyncRead + AsyncWrite + Unpin + Send + 'static,
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
Sourcepub fn driven_by(self, client: &Client) -> DrivenConnection<S, T> ⓘ
pub fn driven_by(self, client: &Client) -> DrivenConnection<S, T> ⓘ
Has client, this connection’s, drive the connection from the calls
that send its requests, on their threads, rather than wake the task
running the connection for each: a request is on its way before the
call that made it first returns. The returned future is spawned in
the connection’s place.
Worth it for calls made from outside the runtime’s threads, each of which would otherwise wait for one to wake.
Trait Implementations§
Source§impl<S, T> Future for Connection<S, T>
impl<S, T> Future for Connection<S, T>
Auto Trait Implementations§
impl<S, T> !Freeze for Connection<S, T>
impl<S, T> !RefUnwindSafe for Connection<S, T>
impl<S, T> !Sync for Connection<S, T>
impl<S, T> !UnwindSafe for Connection<S, T>
impl<S, T> Forget for Connection<S, T>
impl<S, T> Move for Connection<S, T>
impl<S, T> Send for Connection<S, T>
impl<S, T> Unpin for Connection<S, T>where
Framed<MaybeTlsStream<S, T>, PostgresCodec>: Unpin,
*const u8 is !null: Unpin,
UnboundedReceiver<Request>: Unpin,
*const u8: Unpin,
Align8<*mut ()>: Unpin,
&'static Vtable: Unpin,
Box<dyn Buf + Send>: Unpin,
Receiver<CopyInMessage>: Unpin,
*mut Shared: Unpin,
BoundedSenderInner<BackendMessages>: Unpin,
Waker: Unpin,
impl<S, T> UnsafeUnpin for Connection<S, T>where
S: UnsafeUnpin,
T: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
*mut Shared: UnsafeUnpin,
PhantomData<(String, String)>: UnsafeUnpin,
*const ArcInner<UnboundedInner<Request>> is !null: UnsafeUnpin,
PhantomData<ArcInner<UnboundedInner<Request>>>: UnsafeUnpin,
*const u8: UnsafeUnpin,
Align8<*mut ()>: UnsafeUnpin,
&'static Vtable: UnsafeUnpin,
*const dyn Buf + Send is !null: UnsafeUnpin,
PhantomData<dyn Buf + Send>: UnsafeUnpin,
*const ArcInner<BoundedInner<CopyInMessage>> is !null: UnsafeUnpin,
PhantomData<ArcInner<BoundedInner<CopyInMessage>>>: UnsafeUnpin,
PhantomData<BackendMessage>: UnsafeUnpin,
PhantomData<Response>: UnsafeUnpin,
*const (): UnsafeUnpin,
&'static RawWakerVTable: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn map<U, F>(self, f: F) -> Map<Self, F> ⓘ
fn map<U, F>(self, f: F) -> Map<Self, F> ⓘ
Source§fn map_into<U>(self) -> MapInto<Self, U> ⓘ
fn map_into<U>(self) -> MapInto<Self, U> ⓘ
Source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> ⓘ
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> ⓘ
f. Read moreSource§fn left_future<B>(self) -> Either<Self, B> ⓘ
fn left_future<B>(self) -> Either<Self, B> ⓘ
Source§fn right_future<A>(self) -> Either<A, Self> ⓘ
fn right_future<A>(self) -> Either<A, Self> ⓘ
Source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Source§fn flatten(self) -> Flatten<Self> ⓘ
fn flatten(self) -> Flatten<Self> ⓘ
Source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
Source§fn fuse(self) -> Fuse<Self> ⓘwhere
Self: Sized,
fn fuse(self) -> Fuse<Self> ⓘwhere
Self: Sized,
poll will never again be called once it has
completed. This method can be used to turn any Future into a
FusedFuture. Read moreSource§fn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘ
fn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘ
Source§fn catch_unwind(self) -> CatchUnwind<Self> ⓘwhere
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self> ⓘwhere
Self: Sized + UnwindSafe,
Source§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
Source§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
Source§fn unit_error(self) -> UnitError<Self> ⓘwhere
Self: Sized,
fn unit_error(self) -> UnitError<Self> ⓘwhere
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = ()>.Source§fn never_error(self) -> NeverError<Self> ⓘwhere
Self: Sized,
fn never_error(self) -> NeverError<Self> ⓘwhere
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = Never>.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_cancellation_token(
self,
cancellation_token: &CancellationToken,
) -> WithCancellationTokenFuture<'_, Self>where
Self: Sized,
fn with_cancellation_token(
self,
cancellation_token: &CancellationToken,
) -> WithCancellationTokenFuture<'_, Self>where
Self: Sized,
CancellationToken::run_until_cancelled,
but with the advantage that it is easier to write fluent call chains. Read moreSource§fn with_cancellation_token_owned(
self,
cancellation_token: CancellationToken,
) -> WithCancellationTokenFutureOwned<Self>where
Self: Sized,
fn with_cancellation_token_owned(
self,
cancellation_token: CancellationToken,
) -> WithCancellationTokenFutureOwned<Self>where
Self: Sized,
CancellationToken::run_until_cancelled_owned,
but with the advantage that it is easier to write fluent call chains. Read more