Skip to main content

Buffered

Struct Buffered 

Source
pub struct Buffered<S, D = Backend> { /* private fields */ }
Expand description

Transport wrapper which retains bytes until each write has completed.

Implementations§

Source§

impl<S> Buffered<S, Backend>

Source

pub fn new(io: S) -> Self

Wraps an upstream-facing transport which receives backend messages.

Source

pub fn with_max_frame_len(io: S, max_frame_len: usize) -> Result<Self>

Creates a backend-facing transport with a bounded tagged-frame size.

§Errors

Returns an error when the limit is outside PostgreSQL’s frame range.

Source§

impl<S> Buffered<S, Frontend>

Source

pub fn new_frontend(io: S) -> Self

Wraps a client-facing transport which receives frontend messages.

Source

pub fn with_max_frame_len_frontend(io: S, max_frame_len: usize) -> Result<Self>

Creates a frontend-facing transport with a bounded tagged-frame size.

§Errors

Returns an error when the limit is outside PostgreSQL’s frame range.

Source

pub fn with_limits_frontend( io: S, max_frame_len: usize, max_pre_startup_packet_len: usize, ) -> Result<Self>

Creates a frontend-facing transport with bounded tagged and pre-startup packets.

§Errors

Returns an error when either limit is outside PostgreSQL’s framing range.

Source§

impl<S, D> Buffered<S, D>

Source

pub fn push(&mut self, frame: Frame) -> Result<()>

Encodes a frame synchronously into the outbound buffer.

§Errors

Returns an error when the frame is too large to encode.

Source

pub fn pending(&self) -> &[u8]

Returns encoded bytes which have not yet been fully written.

Source

pub fn into_inner(self) -> S

Removes buffering and returns the underlying I/O transport.

Source

pub const fn demux(&self) -> &Demux

Returns the backend asynchronous-message demultiplexer.

Source

pub const fn demux_mut(&mut self) -> &mut Demux

Returns mutable access to the backend asynchronous-message demultiplexer.

Source§

impl<S: AsyncWrite + Unpin, D> Buffered<S, D>

Source

pub async fn flush(&mut self) -> Result<()>

Writes all buffered bytes without consuming the connection.

Completed partial writes are removed immediately. If this future is cancelled, the connection remains owned by the caller and all unwritten bytes remain buffered for the next call.

§Errors

Returns the underlying transport’s write error or WriteZero.

Source§

impl<S: AsyncRead + Unpin, D: Direction> Buffered<S, D>

Source

pub async fn receive_wire(&mut self) -> Result<D::Message>

Receives one typed message in this transport’s inbound direction.

§Errors

Returns decoding and underlying transport read errors, or UnexpectedEof.

Source§

impl<S: AsyncRead + Unpin> Buffered<S, Frontend>

Source

pub async fn receive_pre_startup(&mut self) -> Result<PreStartupMessage>

Receives one raw first packet before tagged frontend framing begins.

§Errors

Returns malformed pre-startup data and underlying transport read errors.

Source§

impl<S: AsyncRead + Unpin> Buffered<S, Backend>

Source

pub async fn receive_backend(&mut self) -> Result<BackendMessage>

Receives one decoded backend message while retaining partial input.

§Errors

Returns decoding and underlying transport read errors, or UnexpectedEof.

Source

pub async fn receive_session(&mut self) -> Result<SessionItem>

Receives the next protocol-advancing message through the async demux.

§Errors

Returns decoding and underlying transport read errors, or UnexpectedEof.

Source

pub fn project_backend( &mut self, message: BackendMessage, ) -> Option<SessionItem>

Projects an inspected or modified backend message into the session stream.

Trait Implementations§

Source§

impl<S: Debug, D: Debug> Debug for Buffered<S, D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: TlsServerEndPoint, D> TlsServerEndPoint for Buffered<S, D>

Source§

fn tls_server_end_point(&self) -> &[u8]

Returns the RFC 5929 channel-binding bytes derived from the peer certificate.

Auto Trait Implementations§

§

impl<S, D = Backend> !Freeze for Buffered<S, D>

§

impl<S, D> RefUnwindSafe for Buffered<S, D>
where S: RefUnwindSafe,

§

impl<S, D> Send for Buffered<S, D>
where S: Send,

§

impl<S, D> Sync for Buffered<S, D>
where S: Sync,

§

impl<S, D> Unpin for Buffered<S, D>
where S: Unpin,

§

impl<S, D> UnsafeUnpin for Buffered<S, D>
where S: UnsafeUnpin,

§

impl<S, D> UnwindSafe for Buffered<S, D>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.