Skip to main content

Intermediary

Struct Intermediary 

Source
pub struct Intermediary<Downstream, Upstream, Policy = NoPipeline> { /* private fields */ }
Expand description

Owns two independently typed sides and optional pipeline orchestration.

Downstream is normally a server-role session facing a client and Upstream is normally a client-role session facing PostgreSQL. No phase, transport, authentication mechanism, or cleanliness index is coupled between them. Policy defaults to NoPipeline; call Self::with_pipeline to opt into bounded pipelining without changing either session type.

Implementations§

Source§

impl<Downstream, Upstream> Intermediary<Downstream, Upstream, NoPipeline>

Source

pub fn new(downstream: Downstream, upstream: Upstream) -> Self

Pairs two independently established protocol sessions.

Source§

impl<Downstream, Upstream, Policy: PipelinePolicy> Intermediary<Downstream, Upstream, Policy>

Source

pub fn with_pipeline<Next: PipelinePolicy>( self, policy: Next, ) -> Intermediary<Downstream, Upstream, Next>

Replaces the pipeline policy while no pipeline operations are outstanding.

§Panics

Panics if operations were accepted before replacing the policy.

Source

pub const fn pipeline(&self) -> &Pipeline<Policy>

Returns the reusable request/response pipeline component.

Source

pub const fn pipeline_mut(&mut self) -> &mut Pipeline<Policy>

Returns mutable access to bounded pipeline orchestration.

Source

pub const fn downstream(&self) -> &Downstream

Borrows the client-facing side without weakening its typestate.

Source

pub const fn upstream(&self) -> &Upstream

Borrows the upstream-facing side without weakening its typestate.

Source

pub const fn sides_mut(&mut self) -> (&mut Downstream, &mut Upstream)

Mutably borrows both sides for transport-level orchestration.

Source

pub fn into_parts(self) -> (Downstream, Upstream)

Deliberately separates the independently typed sessions.

Source

pub fn transition_downstream<Next, Output, Error>( self, transition: impl FnOnce(Downstream) -> Result<(Next, Output), (Downstream, Error)>, ) -> IntermediaryTransition<Self, Intermediary<Next, Upstream, Policy>, Output, Error>

Applies one fallible downstream transition while retaining the upstream session unchanged.

A rejected transition must return its original downstream value, allowing this method to reconstruct the original intermediary without runtime state.

§Errors

Returns the reconstructed intermediary and transition error when the downstream side rejects the transition.

Source

pub fn transition_upstream<Next, Output, Error>( self, transition: impl FnOnce(Upstream) -> Result<(Next, Output), (Upstream, Error)>, ) -> IntermediaryTransition<Self, Intermediary<Downstream, Next, Policy>, Output, Error>

Applies one fallible upstream transition while retaining the downstream session unchanged.

§Errors

Returns the reconstructed intermediary and transition error when the upstream side rejects the transition.

Source

pub fn inspect<Message, Output, Error>( &mut self, message: Message, inspect: impl FnOnce(&mut Downstream, &mut Upstream, Message) -> Result<Output, Error>, ) -> Result<Output, Error>

Runs custom synchronous policy with mutable access to both sides.

The message and result types are chosen by downstream code; pg-proto neither prescribes a rewrite policy nor advances either session implicitly.

§Errors

Returns any error produced by the inspection policy.

Source

pub async fn inspect_async<Message, Output, Error, Work>( &mut self, message: Message, inspect: impl FnOnce(&mut Downstream, &mut Upstream, Message) -> Work, ) -> Result<Output, Error>
where Work: Future<Output = Result<Output, Error>>,

Runs custom asynchronous policy with mutable access to both sides.

§Errors

Returns any error produced by the asynchronous inspection policy.

Trait Implementations§

Source§

impl<Downstream: Debug, Upstream: Debug, Policy: Debug> Debug for Intermediary<Downstream, Upstream, Policy>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Downstream, Upstream, Policy> Freeze for Intermediary<Downstream, Upstream, Policy>
where Downstream: Freeze, Upstream: Freeze, Policy: Freeze,

§

impl<Downstream, Upstream, Policy> RefUnwindSafe for Intermediary<Downstream, Upstream, Policy>
where Downstream: RefUnwindSafe, Upstream: RefUnwindSafe, Policy: RefUnwindSafe,

§

impl<Downstream, Upstream, Policy> Send for Intermediary<Downstream, Upstream, Policy>
where Downstream: Send, Upstream: Send, Policy: Send,

§

impl<Downstream, Upstream, Policy> Sync for Intermediary<Downstream, Upstream, Policy>
where Downstream: Sync, Upstream: Sync, Policy: Sync,

§

impl<Downstream, Upstream, Policy> Unpin for Intermediary<Downstream, Upstream, Policy>
where Downstream: Unpin, Upstream: Unpin, Policy: Unpin,

§

impl<Downstream, Upstream, Policy> UnsafeUnpin for Intermediary<Downstream, Upstream, Policy>
where Downstream: UnsafeUnpin, Upstream: UnsafeUnpin, Policy: UnsafeUnpin,

§

impl<Downstream, Upstream, Policy> UnwindSafe for Intermediary<Downstream, Upstream, Policy>
where Downstream: UnwindSafe, Upstream: UnwindSafe, Policy: 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.