Struct pgwire::codec::FramedConn [−][src]
Expand description
A connection that manages the encoding and decoding of pgwire frames.
Fields
conn_id: u32
inner: Buffer<Framed<Conn<A>, Codec>, BackendMessage>
Implementations
Constructs a new framed connection.
The underlying connection, inner
, is expected to be something like a
TCP stream. Anything that implements AsyncRead
and AsyncWrite
will do.
The supplied conn_id
is used to identify the connection in logging
messages.
Reads and decodes one frontend message from the client.
Blocks until the client sends a complete message. If the client
terminates the stream, returns None
. Returns an error if the client
sends a malformatted message or if the connection underlying is broken.
Encodes and sends one backend message to the client.
Note that the connection is not flushed after calling this method. You
must call FramedConn::flush
explicitly. Returns an error if the
underlying connection is broken.
pub async fn send_all(
&mut self,
messages: impl IntoIterator<Item = BackendMessage>
) -> Result<(), Error>
pub async fn send_all(
&mut self,
messages: impl IntoIterator<Item = BackendMessage>
) -> Result<(), Error>
Encodes and sends the backend messages in the messages
iterator to the
client.
As with FramedConn::send
, the connection is not flushed after
calling this method. You must call FramedConn::flush
explicitly.
Returns an error if the underlying connection is broken.
Injects state that affects how certain backend messages are encoded.
Specifically, the encoding of BackendMessage::DataRow
depends upon the
types of the datums in the row. To avoid including the same type
information in each message, we use this side channel to install the
type information in the codec before sending any data row messages. This
violates the abstraction boundary a bit but results in much better
performance.
Trait Implementations
impl<A> AsyncReady for FramedConn<A> where
A: AsyncRead + AsyncWrite + AsyncReady + Send + Sync + Unpin,
impl<A> AsyncReady for FramedConn<A> where
A: AsyncRead + AsyncWrite + AsyncReady + Send + Sync + Unpin,
Auto Trait Implementations
impl<A> RefUnwindSafe for FramedConn<A> where
A: RefUnwindSafe,
impl<A> Send for FramedConn<A> where
A: Send,
impl<A> Sync for FramedConn<A> where
A: Sync,
impl<A> Unpin for FramedConn<A> where
A: Unpin,
impl<A> UnwindSafe for FramedConn<A> where
A: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more