Skip to main content

TypedSession

Struct TypedSession 

Source
pub struct TypedSession<Transport, Phase, Cleanliness = ()> { /* private fields */ }
Expand description

Transport-carrying typestate for this protocol role.

Implementations§

Source§

impl<Transport, Cleanliness> TypedSession<Transport, Ready, Cleanliness>

Source

pub const fn with_transport(transport: Transport) -> Self

Attaches transport to a session in the initial phase.

Source§

impl<Transport, Phase, Cleanliness> TypedSession<Transport, Phase, Cleanliness>

Source

pub fn map_transport<Next>( self, map: impl FnOnce(Transport) -> Next, ) -> TypedSession<Next, Phase, Cleanliness>

Replaces the transport representation without changing protocol indices.

Source

pub fn into_transport(self) -> Transport

Deliberately leaves the generated typestate API and returns its transport.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, Ready, Cleanliness>

Source

pub fn query<Output, Error>( self, payload: Bytes, handle: impl FnOnce(&mut Transport, Bytes) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Simple, Dirty>, Output), (Self, Error)>

Handles the payload for query; success enters Simple and failure returns the unchanged session.

Source

pub fn begin_extended(self) -> TypedSession<Transport, Building, Cleanliness>

Applies begin_extended and enters Building.

Source

pub fn function_call<Output, Error>( self, payload: FunctionCall, handle: impl FnOnce(&mut Transport, FunctionCall) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, FunctionCalling, Dirty>, Output), (Self, Error)>

Handles the payload for function_call; success enters FunctionCalling and failure returns the unchanged session.

Source

pub fn reset(self) -> TypedSession<Transport, Resetting, Dirty>

Applies reset and enters Resetting.

Source

pub fn terminate(self) -> TypedSession<Transport, Terminated, Cleanliness>

Applies terminate and enters Terminated.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, FunctionCalling, Cleanliness>

Source

pub fn function_response<Output, Error>( self, payload: Bytes, handle: impl FnOnce(&mut Transport, Bytes) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, AwaitingReady, Cleanliness>, Output), (Self, Error)>

Handles the payload for function_response; success enters AwaitingReady and failure returns the unchanged session.

Source

pub fn error<Output, Error>( self, payload: DiagnosticResponse, handle: impl FnOnce(&mut Transport, DiagnosticResponse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Draining, Cleanliness>, Output), (Self, Error)>

Handles the payload for error; success enters Draining and failure returns the unchanged session.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, Simple, Cleanliness>

Source

pub fn continue_response<Output, Error>( self, payload: BackendMessage, handle: impl FnOnce(&mut Transport, BackendMessage) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Simple, Cleanliness>, Output), (Self, Error)>

Handles the payload for continue_response; success enters Simple and failure returns the unchanged session.

Source

pub fn enter_copy_in<Output, Error>( self, payload: CopyResponse, handle: impl FnOnce(&mut Transport, CopyResponse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, CopyIn, Cleanliness>, Output), (Self, Error)>

Handles the payload for enter_copy_in; success enters CopyIn and failure returns the unchanged session.

Source

pub fn enter_copy_out<Output, Error>( self, payload: CopyResponse, handle: impl FnOnce(&mut Transport, CopyResponse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, CopyOut, Cleanliness>, Output), (Self, Error)>

Handles the payload for enter_copy_out; success enters CopyOut and failure returns the unchanged session.

Source

pub fn enter_copy_both<Output, Error>( self, payload: CopyResponse, handle: impl FnOnce(&mut Transport, CopyResponse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, CopyBoth, Cleanliness>, Output), (Self, Error)>

Handles the payload for enter_copy_both; success enters CopyBoth and failure returns the unchanged session.

Source

pub fn ready<Output, Error>( self, payload: TransactionStatus, handle: impl FnOnce(&mut Transport, TransactionStatus) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Ready, Cleanliness>, Output), (Self, Error)>

Handles the payload for ready; success enters Ready and failure returns the unchanged session.

Source

pub fn error<Output, Error>( self, payload: DiagnosticResponse, handle: impl FnOnce(&mut Transport, DiagnosticResponse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Draining, Cleanliness>, Output), (Self, Error)>

Handles the payload for error; success enters Draining and failure returns the unchanged session.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, Building, Cleanliness>

Source

pub fn parse<Output, Error>( self, payload: Parse, handle: impl FnOnce(&mut Transport, Parse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Building, Dirty>, Output), (Self, Error)>

Handles the payload for parse; success enters Building and failure returns the unchanged session.

Source

pub fn describe<Output, Error>( self, payload: Describe, handle: impl FnOnce(&mut Transport, Describe) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Building, Cleanliness>, Output), (Self, Error)>

Handles the payload for describe; success enters Building and failure returns the unchanged session.

Source

pub fn bind<Output, Error>( self, payload: Bind, handle: impl FnOnce(&mut Transport, Bind) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, BoundBuilding, Dirty>, Output), (Self, Error)>

Handles the payload for bind; success enters BoundBuilding and failure returns the unchanged session.

Source

pub fn close<Output, Error>( self, payload: Close, handle: impl FnOnce(&mut Transport, Close) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Building, Cleanliness>, Output), (Self, Error)>

Handles the payload for close; success enters Building and failure returns the unchanged session.

Source

pub fn flush(self) -> TypedSession<Transport, Building, Cleanliness>

Applies flush and enters Building.

Source

pub fn sync(self) -> TypedSession<Transport, AwaitingReady, Cleanliness>

Applies sync and enters AwaitingReady.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, BoundBuilding, Cleanliness>

Source

pub fn parse<Output, Error>( self, payload: Parse, handle: impl FnOnce(&mut Transport, Parse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, BoundBuilding, Dirty>, Output), (Self, Error)>

Handles the payload for parse; success enters BoundBuilding and failure returns the unchanged session.

Source

pub fn describe<Output, Error>( self, payload: Describe, handle: impl FnOnce(&mut Transport, Describe) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, BoundBuilding, Cleanliness>, Output), (Self, Error)>

Handles the payload for describe; success enters BoundBuilding and failure returns the unchanged session.

Source

pub fn bind<Output, Error>( self, payload: Bind, handle: impl FnOnce(&mut Transport, Bind) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, BoundBuilding, Dirty>, Output), (Self, Error)>

Handles the payload for bind; success enters BoundBuilding and failure returns the unchanged session.

Source

pub fn execute<Output, Error>( self, payload: Execute, handle: impl FnOnce(&mut Transport, Execute) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, BoundBuilding, Cleanliness>, Output), (Self, Error)>

Handles the payload for execute; success enters BoundBuilding and failure returns the unchanged session.

Source

pub fn close<Output, Error>( self, payload: Close, handle: impl FnOnce(&mut Transport, Close) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, BoundBuilding, Cleanliness>, Output), (Self, Error)>

Handles the payload for close; success enters BoundBuilding and failure returns the unchanged session.

Source

pub fn flush(self) -> TypedSession<Transport, BoundBuilding, Cleanliness>

Applies flush and enters BoundBuilding.

Source

pub fn sync(self) -> TypedSession<Transport, AwaitingReady, Cleanliness>

Applies sync and enters AwaitingReady.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, AwaitingReady, Cleanliness>

Source

pub fn continue_response<Output, Error>( self, payload: BackendMessage, handle: impl FnOnce(&mut Transport, BackendMessage) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, AwaitingReady, Cleanliness>, Output), (Self, Error)>

Handles the payload for continue_response; success enters AwaitingReady and failure returns the unchanged session.

Source

pub fn ready<Output, Error>( self, payload: TransactionStatus, handle: impl FnOnce(&mut Transport, TransactionStatus) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Ready, Cleanliness>, Output), (Self, Error)>

Handles the payload for ready; success enters Ready and failure returns the unchanged session.

Source

pub fn error<Output, Error>( self, payload: DiagnosticResponse, handle: impl FnOnce(&mut Transport, DiagnosticResponse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Draining, Cleanliness>, Output), (Self, Error)>

Handles the payload for error; success enters Draining and failure returns the unchanged session.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, CopyIn, Cleanliness>

Source

pub fn copy_data<Output, Error>( self, payload: Bytes, handle: impl FnOnce(&mut Transport, Bytes) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, CopyIn, Cleanliness>, Output), (Self, Error)>

Handles the payload for copy_data; success enters CopyIn and failure returns the unchanged session.

Source

pub fn copy_done(self) -> TypedSession<Transport, AwaitingReady, Cleanliness>

Applies copy_done and enters AwaitingReady.

Source

pub fn copy_fail<Output, Error>( self, payload: Bytes, handle: impl FnOnce(&mut Transport, Bytes) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, AwaitingReady, Cleanliness>, Output), (Self, Error)>

Handles the payload for copy_fail; success enters AwaitingReady and failure returns the unchanged session.

Source

pub fn error<Output, Error>( self, payload: DiagnosticResponse, handle: impl FnOnce(&mut Transport, DiagnosticResponse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Draining, Cleanliness>, Output), (Self, Error)>

Handles the payload for error; success enters Draining and failure returns the unchanged session.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, CopyOut, Cleanliness>

Source

pub fn copy_data<Output, Error>( self, payload: Bytes, handle: impl FnOnce(&mut Transport, Bytes) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, CopyOut, Cleanliness>, Output), (Self, Error)>

Handles the payload for copy_data; success enters CopyOut and failure returns the unchanged session.

Source

pub fn copy_done(self) -> TypedSession<Transport, AwaitingReady, Cleanliness>

Applies copy_done and enters AwaitingReady.

Source

pub fn error<Output, Error>( self, payload: DiagnosticResponse, handle: impl FnOnce(&mut Transport, DiagnosticResponse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Draining, Cleanliness>, Output), (Self, Error)>

Handles the payload for error; success enters Draining and failure returns the unchanged session.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, CopyBoth, Cleanliness>

Source

pub fn send_copy_data<Output, Error>( self, payload: Bytes, handle: impl FnOnce(&mut Transport, Bytes) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, CopyBoth, Cleanliness>, Output), (Self, Error)>

Handles the payload for send_copy_data; success enters CopyBoth and failure returns the unchanged session.

Source

pub fn receive_copy_data<Output, Error>( self, payload: Bytes, handle: impl FnOnce(&mut Transport, Bytes) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, CopyBoth, Cleanliness>, Output), (Self, Error)>

Handles the payload for receive_copy_data; success enters CopyBoth and failure returns the unchanged session.

Source

pub fn send_copy_done( self, ) -> TypedSession<Transport, CopyBothClientDone, Cleanliness>

Applies send_copy_done and enters CopyBothClientDone.

Source

pub fn receive_copy_done( self, ) -> TypedSession<Transport, CopyBothServerDone, Cleanliness>

Applies receive_copy_done and enters CopyBothServerDone.

Source

pub fn error<Output, Error>( self, payload: DiagnosticResponse, handle: impl FnOnce(&mut Transport, DiagnosticResponse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Draining, Cleanliness>, Output), (Self, Error)>

Handles the payload for error; success enters Draining and failure returns the unchanged session.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, CopyBothClientDone, Cleanliness>

Source

pub fn receive_copy_data<Output, Error>( self, payload: Bytes, handle: impl FnOnce(&mut Transport, Bytes) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, CopyBothClientDone, Cleanliness>, Output), (Self, Error)>

Handles the payload for receive_copy_data; success enters CopyBothClientDone and failure returns the unchanged session.

Source

pub fn receive_copy_done( self, ) -> TypedSession<Transport, AwaitingReady, Cleanliness>

Applies receive_copy_done and enters AwaitingReady.

Source

pub fn error<Output, Error>( self, payload: DiagnosticResponse, handle: impl FnOnce(&mut Transport, DiagnosticResponse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Draining, Cleanliness>, Output), (Self, Error)>

Handles the payload for error; success enters Draining and failure returns the unchanged session.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, CopyBothServerDone, Cleanliness>

Source

pub fn send_copy_data<Output, Error>( self, payload: Bytes, handle: impl FnOnce(&mut Transport, Bytes) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, CopyBothServerDone, Cleanliness>, Output), (Self, Error)>

Handles the payload for send_copy_data; success enters CopyBothServerDone and failure returns the unchanged session.

Source

pub fn send_copy_done( self, ) -> TypedSession<Transport, AwaitingReady, Cleanliness>

Applies send_copy_done and enters AwaitingReady.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, Draining, Cleanliness>

Source

pub fn continue_response<Output, Error>( self, payload: BackendMessage, handle: impl FnOnce(&mut Transport, BackendMessage) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Draining, Cleanliness>, Output), (Self, Error)>

Handles the payload for continue_response; success enters Draining and failure returns the unchanged session.

Source

pub fn ready<Output, Error>( self, payload: TransactionStatus, handle: impl FnOnce(&mut Transport, TransactionStatus) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Ready, Cleanliness>, Output), (Self, Error)>

Handles the payload for ready; success enters Ready and failure returns the unchanged session.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, Resetting, Cleanliness>

Source

pub fn continue_reset<Output, Error>( self, payload: BackendMessage, handle: impl FnOnce(&mut Transport, BackendMessage) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Resetting, Cleanliness>, Output), (Self, Error)>

Handles the payload for continue_reset; success enters Resetting and failure returns the unchanged session.

Source

pub fn discard_complete<Output, Error>( self, payload: Bytes, handle: impl FnOnce(&mut Transport, Bytes) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, ResetComplete, Cleanliness>, Output), (Self, Error)>

Handles the payload for discard_complete; success enters ResetComplete and failure returns the unchanged session.

Source

pub fn error<Output, Error>( self, payload: DiagnosticResponse, handle: impl FnOnce(&mut Transport, DiagnosticResponse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Draining, Cleanliness>, Output), (Self, Error)>

Handles the payload for error; success enters Draining and failure returns the unchanged session.

Source§

impl<Transport, Cleanliness> TypedSession<Transport, ResetComplete, Cleanliness>

Source

pub fn continue_reset<Output, Error>( self, payload: BackendMessage, handle: impl FnOnce(&mut Transport, BackendMessage) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, ResetComplete, Cleanliness>, Output), (Self, Error)>

Handles the payload for continue_reset; success enters ResetComplete and failure returns the unchanged session.

Source

pub fn ready_clean<Output, Error>( self, payload: TransactionStatus, handle: impl FnOnce(&mut Transport, TransactionStatus) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Ready, Pristine>, Output), (Self, Error)>

Handles the payload for ready_clean; success enters Ready and failure returns the unchanged session.

Source

pub fn ready_dirty<Output, Error>( self, payload: TransactionStatus, handle: impl FnOnce(&mut Transport, TransactionStatus) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Ready, Dirty>, Output), (Self, Error)>

Handles the payload for ready_dirty; success enters Ready and failure returns the unchanged session.

Source

pub fn error<Output, Error>( self, payload: DiagnosticResponse, handle: impl FnOnce(&mut Transport, DiagnosticResponse) -> Result<Output, Error>, ) -> Result<(TypedSession<Transport, Draining, Cleanliness>, Output), (Self, Error)>

Handles the payload for error; success enters Draining and failure returns the unchanged session.

Trait Implementations§

Source§

impl<Transport: Debug, Phase: Debug, Cleanliness: Debug> Debug for TypedSession<Transport, Phase, Cleanliness>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Transport, Phase, Cleanliness> Freeze for TypedSession<Transport, Phase, Cleanliness>
where Transport: Freeze,

§

impl<Transport, Phase, Cleanliness> RefUnwindSafe for TypedSession<Transport, Phase, Cleanliness>
where Transport: RefUnwindSafe, Phase: RefUnwindSafe, Cleanliness: RefUnwindSafe,

§

impl<Transport, Phase, Cleanliness> Send for TypedSession<Transport, Phase, Cleanliness>
where Transport: Send, Phase: Send, Cleanliness: Send,

§

impl<Transport, Phase, Cleanliness> Sync for TypedSession<Transport, Phase, Cleanliness>
where Transport: Sync, Phase: Sync, Cleanliness: Sync,

§

impl<Transport, Phase, Cleanliness> Unpin for TypedSession<Transport, Phase, Cleanliness>
where Transport: Unpin, Phase: Unpin, Cleanliness: Unpin,

§

impl<Transport, Phase, Cleanliness> UnsafeUnpin for TypedSession<Transport, Phase, Cleanliness>
where Transport: UnsafeUnpin,

§

impl<Transport, Phase, Cleanliness> UnwindSafe for TypedSession<Transport, Phase, Cleanliness>
where Transport: UnwindSafe, Phase: UnwindSafe, Cleanliness: 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.