pub struct Conn<Transport, Phase, Cleanliness = Pristine> { /* private fields */ }Expand description
A connection whose legal operations are selected by Phase and Cleanliness.
Implementations§
Source§impl<S: TlsServerEndPoint, Phase, Cleanliness> Conn<S, Phase, Cleanliness>
impl<S: TlsServerEndPoint, Phase, Cleanliness> Conn<S, Phase, Cleanliness>
Sourcepub fn tls_server_end_point(&self) -> &[u8] ⓘ
pub fn tls_server_end_point(&self) -> &[u8] ⓘ
Returns the peer-certificate binding for custom authentication policy.
Source§impl<S> Conn<S, Startup, Pristine>
impl<S> Conn<S, Startup, Pristine>
Sourcepub fn authentication(self) -> Conn<S, Auth>
pub fn authentication(self) -> Conn<S, Auth>
Enters backend-driven authentication after sending the startup message.
Source§impl<S> Conn<S, Auth, Pristine>
impl<S> Conn<S, Auth, Pristine>
Sourcepub fn offer_backend(
self,
message: BackendMessage,
) -> Result<AuthEvent<S>, (Self, BackendMessage, Option<Error>)>
pub fn offer_backend( self, message: BackendMessage, ) -> Result<AuthEvent<S>, (Self, BackendMessage, Option<Error>)>
Projects either protocol negotiation or an authentication request.
§Errors
Returns an authentication parsing error, or the unchanged connection and message when the backend message is unrelated to startup authentication.
§Panics
Panics only if the exhaustive continuation guard above the internal
projection becomes inconsistent with Self::offer.
Source§impl<S> Conn<S, TokenResponse, Pristine>
impl<S> Conn<S, TokenResponse, Pristine>
Source§impl<S> Conn<S, TokenChallenge, Pristine>
impl<S> Conn<S, TokenChallenge, Pristine>
Sourcepub fn offer(
self,
message: BackendMessage,
) -> Result<TokenAuthEvent<S>, (Self, BackendMessage)>
pub fn offer( self, message: BackendMessage, ) -> Result<TokenAuthEvent<S>, (Self, BackendMessage)>
Projects recursive GSS continuation, successful authentication, or failure.
§Errors
Returns the live connection and message for an illegal response.
Source§impl<S> Conn<S, PasswordResponse, Pristine>
impl<S> Conn<S, PasswordResponse, Pristine>
Source§impl<S> Conn<S, SaslInitial, Pristine>
impl<S> Conn<S, SaslInitial, Pristine>
Source§impl<S: TlsServerEndPoint> Conn<S, SaslInitial, Pristine>
impl<S: TlsServerEndPoint> Conn<S, SaslInitial, Pristine>
Source§impl<S> Conn<S, Sasl, Pristine>
impl<S> Conn<S, Sasl, Pristine>
Sourcepub fn offer(
self,
authentication: Authentication,
) -> Result<SaslEvent<S>, (Self, Authentication)>
pub fn offer( self, authentication: Authentication, ) -> Result<SaslEvent<S>, (Self, Authentication)>
Projects the next server challenge or final verifier.
§Errors
Returns the live connection and authentication message for an illegal branch.
Sourcepub fn offer_backend(
self,
message: BackendMessage,
) -> Result<SaslEvent<S>, (Self, BackendMessage)>
pub fn offer_backend( self, message: BackendMessage, ) -> Result<SaslEvent<S>, (Self, BackendMessage)>
Projects an authentication error which terminates an active SASL exchange.
§Errors
Returns the live connection and message for an illegal response.
Source§impl<S> Conn<S, SaslChallenge, Pristine>
impl<S> Conn<S, SaslChallenge, Pristine>
Source§impl<S> Conn<S, SaslFinal, Pristine>
impl<S> Conn<S, SaslFinal, Pristine>
Sourcepub fn verified(self) -> Conn<S, AwaitingAuthOk>
pub fn verified(self) -> Conn<S, AwaitingAuthOk>
Records that custom SCRAM logic verified the received server-final value.
Source§impl<S> Conn<S, AwaitingAuthOk, Pristine>
impl<S> Conn<S, AwaitingAuthOk, Pristine>
Sourcepub fn offer(
self,
message: BackendMessage,
) -> Result<AuthCompletion<S>, (Self, BackendMessage)>
pub fn offer( self, message: BackendMessage, ) -> Result<AuthCompletion<S>, (Self, BackendMessage)>
Requires backend evidence that authentication succeeded or failed.
§Errors
Returns the live connection and message for an illegal response.
Source§impl<S> Conn<S, AwaitingStartupReady, Pristine>
impl<S> Conn<S, AwaitingStartupReady, Pristine>
Sourcepub fn offer_ready(
self,
item: SessionItem,
) -> Result<Conn<S, Ready>, (Self, SessionItem)>
pub fn offer_ready( self, item: SessionItem, ) -> Result<Conn<S, Ready>, (Self, SessionItem)>
Completes startup only when presented with a projected ReadyForQuery.
§Errors
Returns the unchanged connection and item when it is not ReadyForQuery.
Source§impl<S, P: 'static, C: 'static> Conn<S, P, C>
impl<S, P: 'static, C: 'static> Conn<S, P, C>
Sourcepub fn erase(self) -> ErasedConn<S>
pub fn erase(self) -> ErasedConn<S>
Erases monomorphised state markers while retaining their exact runtime identities for checked re-entry.
Source§impl<S> Conn<S, PreStartup, Pristine>
impl<S> Conn<S, PreStartup, Pristine>
Sourcepub fn ssl_request(self) -> (Conn<S, AwaitingSslReply>, [u8; 8])
pub fn ssl_request(self) -> (Conn<S, AwaitingSslReply>, [u8; 8])
Encodes SSLRequest and enters the raw-reply phase.
Sourcepub fn gssenc_request(self) -> (Conn<S, AwaitingGssReply>, [u8; 8])
pub fn gssenc_request(self) -> (Conn<S, AwaitingGssReply>, [u8; 8])
Encodes GSSENCRequest and enters the raw-reply phase.
Sourcepub fn startup(
self,
message: &StartupMessage,
) -> Result<(Conn<S, Startup>, Bytes)>
pub fn startup( self, message: &StartupMessage, ) -> Result<(Conn<S, Startup>, Bytes)>
Encodes and enters the startup phase.
§Errors
Returns an error when the startup parameters cannot be encoded.
Sourcepub fn cancel_request(
self,
process_id: u32,
secret_key: &[u8],
) -> Result<(Conn<S, Terminated>, Bytes)>
pub fn cancel_request( self, process_id: u32, secret_key: &[u8], ) -> Result<(Conn<S, Terminated>, Bytes)>
Encodes a version 3.0 or 3.2 out-of-band cancellation request.
§Errors
Returns an error unless the cancellation key is between 4 and 256 bytes.
Source§impl<S, C> Conn<S, PreStartup, C>
impl<S, C> Conn<S, PreStartup, C>
Sourcepub fn offer_pre_startup(
self,
message: PreStartupMessage,
) -> PreStartupOffer<S, C>
pub fn offer_pre_startup( self, message: PreStartupMessage, ) -> PreStartupOffer<S, C>
Projects an inspected client pre-startup packet into the server role.
Source§impl<S, C> Conn<S, ServerSslDecision, C>
impl<S, C> Conn<S, ServerSslDecision, C>
Sourcepub fn reject_ssl(self) -> (Conn<S, PreStartup, C>, u8)
pub fn reject_ssl(self) -> (Conn<S, PreStartup, C>, u8)
Rejects SSL and returns to the pre-startup choice on the same transport.
Sourcepub fn accept_ssl(self) -> (Conn<S, TlsHandshake, C>, u8)
pub fn accept_ssl(self) -> (Conn<S, TlsHandshake, C>, u8)
Accepts SSL and requires the transport handshake before startup is legal.
Sourcepub fn legacy_ssl_error(self) -> (Conn<S, Terminated, C>, u8)
pub fn legacy_ssl_error(self) -> (Conn<S, Terminated, C>, u8)
Emits the historical raw E response and terminates negotiation.
Source§impl<S, C> Conn<S, ServerGssDecision, C>
impl<S, C> Conn<S, ServerGssDecision, C>
Sourcepub fn reject_gss(self) -> (Conn<S, PreStartup, C>, u8)
pub fn reject_gss(self) -> (Conn<S, PreStartup, C>, u8)
Sends N and returns to plaintext pre-startup choice.
Sourcepub fn accept_gss(self) -> (Conn<S, GssHandshake, C>, u8)
pub fn accept_gss(self) -> (Conn<S, GssHandshake, C>, u8)
Sends S and requires a server-side GSS transport handshake.
Sourcepub fn legacy_gss_error(self) -> (Conn<S, Terminated, C>, u8)
pub fn legacy_gss_error(self) -> (Conn<S, Terminated, C>, u8)
Emits the historical raw E response and terminates negotiation.
Source§impl<S, C> Conn<S, AwaitingSslReply, C>
impl<S, C> Conn<S, AwaitingSslReply, C>
Sourcepub fn receive_reply(
self,
reply: EncryptionReply,
) -> Negotiation<S, TlsHandshake, C>
pub fn receive_reply( self, reply: EncryptionReply, ) -> Negotiation<S, TlsHandshake, C>
Resolves the raw SSL response byte.
A pending negotiation cannot send a startup message:
use pg_proto::Conn;
let (pending, _) = Conn::new(()).ssl_request();
let _ = pending.startup();Sourcepub fn apply_ssl_reply(
self,
reply: EncryptionReply,
mode: SslMode,
) -> SslModeNegotiation<S, C>
pub fn apply_ssl_reply( self, reply: EncryptionReply, mode: SslMode, ) -> SslModeNegotiation<S, C>
Resolves the SSL response while enforcing an SslMode’s fallback rule.
Source§impl<S, C> Conn<S, AwaitingGssReply, C>
impl<S, C> Conn<S, AwaitingGssReply, C>
Sourcepub fn receive_reply(
self,
reply: EncryptionReply,
) -> Negotiation<S, GssHandshake, C>
pub fn receive_reply( self, reply: EncryptionReply, ) -> Negotiation<S, GssHandshake, C>
Applies the server’s GSS encryption decision byte.
Source§impl<S, C> Conn<S, TlsHandshake, C>
impl<S, C> Conn<S, TlsHandshake, C>
Sourcepub fn finish_tls<Tls>(
self,
upgrade: impl FnOnce(S) -> Tls,
) -> Conn<Tls, PreStartup, C>
pub fn finish_tls<Tls>( self, upgrade: impl FnOnce(S) -> Tls, ) -> Conn<Tls, PreStartup, C>
Records a completed in-place TLS upgrade, changing the transport type.
Source§impl<S, C> Conn<S, TlsHandshake, C>
impl<S, C> Conn<S, TlsHandshake, C>
Sourcepub fn finish_server_tls<Tls>(
self,
upgrade: impl FnOnce(S) -> Tls,
) -> Conn<Tls, PreStartup, C>
pub fn finish_server_tls<Tls>( self, upgrade: impl FnOnce(S) -> Tls, ) -> Conn<Tls, PreStartup, C>
Records a server-side TLS upgrade while preserving cleanliness.
Source§impl<S> Conn<S, GssHandshake, Pristine>
impl<S> Conn<S, GssHandshake, Pristine>
Sourcepub fn finish_gss<Gss>(
self,
upgrade: impl FnOnce(S) -> Gss,
) -> Conn<Gss, PreStartup>
pub fn finish_gss<Gss>( self, upgrade: impl FnOnce(S) -> Gss, ) -> Conn<Gss, PreStartup>
Records a completed in-place GSS encryption upgrade.
Source§impl<S, C> Conn<S, GssHandshake, C>
impl<S, C> Conn<S, GssHandshake, C>
Sourcepub fn finish_server_gss<Gss>(
self,
upgrade: impl FnOnce(S) -> Gss,
) -> Conn<Gss, PreStartup, C>
pub fn finish_server_gss<Gss>( self, upgrade: impl FnOnce(S) -> Gss, ) -> Conn<Gss, PreStartup, C>
Completes a server-side GSS upgrade and returns to encrypted pre-startup.
Source§impl<S, C> Conn<S, Startup, C>
impl<S, C> Conn<S, Startup, C>
Sourcepub fn validate_protocol(
self,
message: StartupMessage,
newest: ProtocolVersion,
) -> ServerProtocolOffer<S, C>
pub fn validate_protocol( self, message: StartupMessage, newest: ProtocolVersion, ) -> ServerProtocolOffer<S, C>
Validates the startup protocol before authentication can begin.
Source§impl<S, C> Conn<S, ServerStartupValidated, C>
impl<S, C> Conn<S, ServerStartupValidated, C>
Sourcepub fn begin_server_auth(self) -> Conn<S, ServerAuth, C>
pub fn begin_server_auth(self) -> Conn<S, ServerAuth, C>
Begins proxy-side authentication of a protocol-compatible client.
Source§impl<S, C> Conn<S, ServerStartupRejected, C>
impl<S, C> Conn<S, ServerStartupRejected, C>
Sourcepub fn error(
self,
response: DiagnosticResponse,
) -> Result<(Conn<S, Terminated, C>, Frame)>
pub fn error( self, response: DiagnosticResponse, ) -> Result<(Conn<S, Terminated, C>, Frame)>
Rejects an unsupported major protocol version and terminates the session.
§Errors
Returns an error if a diagnostic field is invalid.
Source§impl<S, C> Conn<S, ServerAuth, C>
impl<S, C> Conn<S, ServerAuth, C>
Sourcepub fn request_cleartext(self) -> Result<(Conn<S, ServerPassword, C>, Frame)>
pub fn request_cleartext(self) -> Result<(Conn<S, ServerPassword, C>, Frame)>
Requests a cleartext password from the client.
§Errors
Returns an error only if the fixed authentication message cannot be encoded.
Sourcepub fn request_md5(
self,
salt: [u8; 4],
) -> Result<(Conn<S, ServerPassword, C>, Frame)>
pub fn request_md5( self, salt: [u8; 4], ) -> Result<(Conn<S, ServerPassword, C>, Frame)>
Requests a PostgreSQL MD5 password response from the client.
§Errors
Returns an error only if the authentication message cannot be encoded.
Sourcepub fn request_sasl(
self,
mechanisms: Vec<Bytes>,
) -> Result<(Conn<S, ServerSaslInitial, C>, Frame)>
pub fn request_sasl( self, mechanisms: Vec<Bytes>, ) -> Result<(Conn<S, ServerSaslInitial, C>, Frame)>
Offers one or more SASL mechanisms to the client.
§Errors
Returns an error if a mechanism contains a NUL byte.
Sourcepub fn request_kerberos_v5(
self,
) -> Result<(Conn<S, ServerAuthResponse, C>, Frame)>
pub fn request_kerberos_v5( self, ) -> Result<(Conn<S, ServerAuthResponse, C>, Frame)>
Requests Kerberos V5 authentication.
§Errors
Returns an error only if the fixed authentication message cannot be encoded.
Sourcepub fn request_gss(self) -> Result<(Conn<S, ServerAuthResponse, C>, Frame)>
pub fn request_gss(self) -> Result<(Conn<S, ServerAuthResponse, C>, Frame)>
Requests GSSAPI authentication.
§Errors
Returns an error only if the fixed authentication message cannot be encoded.
Sourcepub fn request_sspi(self) -> Result<(Conn<S, ServerAuthResponse, C>, Frame)>
pub fn request_sspi(self) -> Result<(Conn<S, ServerAuthResponse, C>, Frame)>
Requests SSPI authentication.
§Errors
Returns an error only if the fixed authentication message cannot be encoded.
Sourcepub fn authentication_ok(
self,
) -> Result<(Conn<S, ServerStartupReady, C>, Frame)>
pub fn authentication_ok( self, ) -> Result<(Conn<S, ServerStartupReady, C>, Frame)>
Confirms authentication and enters the startup-completion phase.
§Errors
Returns an error only if the fixed authentication message cannot be encoded.
Source§impl<S, C> Conn<S, ServerPassword, C>
impl<S, C> Conn<S, ServerPassword, C>
Sourcepub fn receive_password(
self,
message: FrontendMessage,
) -> PasswordProjection<S, C>
pub fn receive_password( self, message: FrontendMessage, ) -> PasswordProjection<S, C>
Projects the inspected password response and returns to policy evaluation.
§Errors
Returns the unchanged state and message if it is not a valid password response.
Source§impl<S, C> Conn<S, ServerSaslInitial, C>
impl<S, C> Conn<S, ServerSaslInitial, C>
Sourcepub fn receive_initial(
self,
message: FrontendMessage,
) -> SaslInitialProjection<S, C>
pub fn receive_initial( self, message: FrontendMessage, ) -> SaslInitialProjection<S, C>
Projects the client’s selected SASL mechanism and initial response.
§Errors
Returns the unchanged state and message if the SASL initial response is malformed.
Source§impl<S, C> Conn<S, ServerSasl, C>
impl<S, C> Conn<S, ServerSasl, C>
Sourcepub fn receive_response(
self,
message: FrontendMessage,
) -> ServerProjection<(Self, Bytes), S, ServerSasl, C>
pub fn receive_response( self, message: FrontendMessage, ) -> ServerProjection<(Self, Bytes), S, ServerSasl, C>
Projects one client SASL response and remains in the recursive exchange.
§Errors
Returns the unchanged state and message if it is not a SASL response.
Source§impl<S, C> Conn<S, ServerAuthResponse, C>
impl<S, C> Conn<S, ServerAuthResponse, C>
Sourcepub fn receive_response(
self,
message: FrontendMessage,
) -> ServerProjection<(Self, Bytes), S, ServerAuthResponse, C>
pub fn receive_response( self, message: FrontendMessage, ) -> ServerProjection<(Self, Bytes), S, ServerAuthResponse, C>
Projects one GSS, SSPI, or Kerberos response token.
§Errors
Returns the unchanged state and message if it is not an authentication token.
Sourcepub fn continue_gss(self, token: Bytes) -> Result<(Self, Frame)>
pub fn continue_gss(self, token: Bytes) -> Result<(Self, Frame)>
Sends a GSS continuation token and remains in the authentication exchange.
§Errors
Returns an error only if the authentication message cannot be encoded.
Sourcepub fn verified(self) -> Conn<S, ServerAuth, C>
pub fn verified(self) -> Conn<S, ServerAuth, C>
Returns to policy evaluation after the mechanism verifies its response.
Source§impl<S, C> Conn<S, ServerStartupReady, C>
impl<S, C> Conn<S, ServerStartupReady, C>
Sourcepub fn parameter_status(
self,
name: Bytes,
value: Bytes,
) -> Result<(Self, Frame)>
pub fn parameter_status( self, name: Bytes, value: Bytes, ) -> Result<(Self, Frame)>
Emits a startup parameter while remaining before ReadyForQuery.
§Errors
Returns an error if either value contains a NUL byte.
Sourcepub fn backend_key_data(
self,
process_id: u32,
secret_key: Bytes,
) -> Result<(Self, Frame)>
pub fn backend_key_data( self, process_id: u32, secret_key: Bytes, ) -> Result<(Self, Frame)>
Emits the proxy-minted cancellation key exposed to this client.
§Errors
Returns an error if the key is outside the protocol’s 4–256 byte range.
Sourcepub fn negotiate_protocol(
self,
newest: ProtocolVersion,
unsupported_options: Vec<Bytes>,
) -> Result<(Self, Frame)>
pub fn negotiate_protocol( self, newest: ProtocolVersion, unsupported_options: Vec<Bytes>, ) -> Result<(Self, Frame)>
Responds to unsupported protocol 3.1/3.2 startup options.
§Errors
Returns an error if an option name contains a NUL byte or counts overflow.
Source§impl<S, C> Conn<S, Ready, C>
impl<S, C> Conn<S, Ready, C>
Sourcepub fn offer_frontend(self, message: FrontendMessage) -> ReadyProjection<S, C>
pub fn offer_frontend(self, message: FrontendMessage) -> ReadyProjection<S, C>
Projects an inspected client message into the server-role ready state.
§Errors
Returns the unchanged connection and message for choices not yet legal in this simple-query projection.
Sourcepub fn accept_stateless_query(
self,
query: Bytes,
) -> (Conn<S, ServerSimpleQuery, C>, Bytes)
pub fn accept_stateless_query( self, query: Bytes, ) -> (Conn<S, ServerSimpleQuery, C>, Bytes)
Accepts inspected query text which cannot retain client session state.
Sourcepub fn accept_stateless_function_call(
self,
message: FunctionCall,
) -> (Conn<S, ServerFunctionCall, C>, FunctionCall)
pub fn accept_stateless_function_call( self, message: FunctionCall, ) -> (Conn<S, ServerFunctionCall, C>, FunctionCall)
Accepts an allow-listed function call known not to retain session state.
Source§impl<S, C> Conn<S, ServerFunctionCall, C>
impl<S, C> Conn<S, ServerFunctionCall, C>
Sourcepub fn respond(
self,
value: Bytes,
) -> Result<(Conn<S, ServerFunctionCallDone, C>, Frame)>
pub fn respond( self, value: Bytes, ) -> Result<(Conn<S, ServerFunctionCallDone, C>, Frame)>
Sends the typed function result before the mandatory ready message.
§Errors
Returns an error if the result is too large for a wire frame.
Sourcepub fn error(
self,
response: DiagnosticResponse,
) -> Result<(Conn<S, ServerFunctionCallError, C>, Frame)>
pub fn error( self, response: DiagnosticResponse, ) -> Result<(Conn<S, ServerFunctionCallError, C>, Frame)>
Rejects the call before the mandatory ready message.
§Errors
Returns an error if a diagnostic field is invalid.
Source§impl<S, C> Conn<S, ServerFunctionCallDone, C>
impl<S, C> Conn<S, ServerFunctionCallDone, C>
Sourcepub fn ready(
self,
status: TransactionStatus,
) -> Result<(ServerReadyState<S, C>, Frame)>
pub fn ready( self, status: TransactionStatus, ) -> Result<(ServerReadyState<S, C>, Frame)>
Sends readiness after a successful function call.
§Errors
Returns an error only if the fixed ready message cannot be encoded.
Source§impl<S, C> Conn<S, ServerFunctionCallError, C>
impl<S, C> Conn<S, ServerFunctionCallError, C>
Sourcepub fn ready(
self,
status: TransactionStatus,
) -> Result<(ServerReadyState<S, C>, Frame)>
pub fn ready( self, status: TransactionStatus, ) -> Result<(ServerReadyState<S, C>, Frame)>
Sends readiness after a failed function call.
§Errors
Returns an error only if the fixed ready message cannot be encoded.
Source§impl<S, C> Conn<S, ServerBuilding, C>
impl<S, C> Conn<S, ServerBuilding, C>
Sourcepub fn offer_frontend(
self,
message: FrontendMessage,
) -> ExtendedProjection<S, ServerBuilding, C>
pub fn offer_frontend( self, message: FrontendMessage, ) -> ExtendedProjection<S, ServerBuilding, C>
Projects the next inspected message in an extended-query pipeline.
§Errors
Returns the unchanged state and message if it is not legal before Sync.
Source§impl<S, C> Conn<S, ServerSimpleQuery, C>
impl<S, C> Conn<S, ServerSimpleQuery, C>
Sourcepub fn send(self, message: &BackendMessage) -> Result<(Self, Frame)>
pub fn send(self, message: &BackendMessage) -> Result<(Self, Frame)>
Sends a non-terminal typed result message after proxy inspection or rewriting.
§Errors
Returns an error if the message cannot be reconstructed, or if it would prematurely change the simple-query state.
Sourcepub fn error(
self,
response: DiagnosticResponse,
) -> Result<(Conn<S, ServerSimpleError, C>, Frame)>
pub fn error( self, response: DiagnosticResponse, ) -> Result<(Conn<S, ServerSimpleError, C>, Frame)>
Sends an error response before the mandatory ReadyForQuery.
§Errors
Returns an error if a diagnostic field is invalid.
Sourcepub fn copy_in(self, response: CopyResponse) -> CopyInStart<S, C, CopySimple>
pub fn copy_in(self, response: CopyResponse) -> CopyInStart<S, C, CopySimple>
Starts a simple-query COPY IN sub-session.
§Errors
Returns an error if the format count overflows the protocol field.
Sourcepub fn copy_out(self, response: CopyResponse) -> CopyOutStart<S, C, CopySimple>
pub fn copy_out(self, response: CopyResponse) -> CopyOutStart<S, C, CopySimple>
Starts a simple-query COPY OUT sub-session.
§Errors
Returns an error if the format count overflows the protocol field.
Sourcepub fn copy_both(
self,
response: CopyResponse,
) -> CopyBothStart<S, C, CopySimple>
pub fn copy_both( self, response: CopyResponse, ) -> CopyBothStart<S, C, CopySimple>
Starts a simple-query COPY BOTH sub-session.
§Errors
Returns an error if the format count overflows the protocol field.
Sourcepub fn ready(
self,
status: TransactionStatus,
) -> Result<(ServerReadyState<S, C>, Frame)>
pub fn ready( self, status: TransactionStatus, ) -> Result<(ServerReadyState<S, C>, Frame)>
Ends a successful simple-query exchange and surfaces transaction status.
§Errors
Returns an error only if the fixed ready message cannot be encoded.
Source§impl<S, C> Conn<S, ServerSimpleError, C>
impl<S, C> Conn<S, ServerSimpleError, C>
Sourcepub fn ready(
self,
status: TransactionStatus,
) -> Result<(ServerReadyState<S, C>, Frame)>
pub fn ready( self, status: TransactionStatus, ) -> Result<(ServerReadyState<S, C>, Frame)>
Ends an errored simple-query exchange and surfaces transaction status.
§Errors
Returns an error only if the fixed ready message cannot be encoded.
Source§impl<S, C> Conn<S, ServerParse, C>
impl<S, C> Conn<S, ServerParse, C>
Sourcepub fn complete(self) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
pub fn complete(self) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
Confirms a successful Parse and returns to the building loop.
§Errors
Returns an error only if the fixed response cannot be encoded.
Sourcepub fn error(
self,
response: DiagnosticResponse,
) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
pub fn error( self, response: DiagnosticResponse, ) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
Rejects Parse and begins discarding the pipeline until Sync.
§Errors
Returns an error if a diagnostic field is invalid.
Source§impl<S, C> Conn<S, ServerBind, C>
impl<S, C> Conn<S, ServerBind, C>
Sourcepub fn complete(self) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
pub fn complete(self) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
Confirms a successful Bind and returns to the building loop.
§Errors
Returns an error only if the fixed response cannot be encoded.
Sourcepub fn error(
self,
response: DiagnosticResponse,
) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
pub fn error( self, response: DiagnosticResponse, ) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
Rejects Bind and begins discarding the pipeline until Sync.
§Errors
Returns an error if a diagnostic field is invalid.
Source§impl<S, C> Conn<S, ServerClose, C>
impl<S, C> Conn<S, ServerClose, C>
Sourcepub fn complete(self) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
pub fn complete(self) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
Confirms Close and returns to the building loop.
§Errors
Returns an error only if the fixed response cannot be encoded.
Sourcepub fn error(
self,
response: DiagnosticResponse,
) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
pub fn error( self, response: DiagnosticResponse, ) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
Rejects Close and begins discarding the pipeline until Sync.
§Errors
Returns an error if a diagnostic field is invalid.
Source§impl<S, C> Conn<S, ServerDescribe, C>
impl<S, C> Conn<S, ServerDescribe, C>
Sourcepub fn parameter_description(self, oids: Vec<u32>) -> Result<(Self, Frame)>
pub fn parameter_description(self, oids: Vec<u32>) -> Result<(Self, Frame)>
Sends statement parameter OIDs before its row metadata.
§Errors
Returns an error if the OID count overflows the protocol field.
Sourcepub fn row_description(
self,
description: RowDescription,
) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
pub fn row_description( self, description: RowDescription, ) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
Sends reconstructable row metadata and returns to the building loop.
§Errors
Returns an error if field metadata is invalid.
Sourcepub fn no_data(self) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
pub fn no_data(self) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
Sends NoData and returns to the building loop.
§Errors
Returns an error only if the fixed response cannot be encoded.
Sourcepub fn error(
self,
response: DiagnosticResponse,
) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
pub fn error( self, response: DiagnosticResponse, ) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
Rejects Describe and begins discarding the pipeline until Sync.
§Errors
Returns an error if a diagnostic field is invalid.
Source§impl<S, C> Conn<S, ServerExecute, C>
impl<S, C> Conn<S, ServerExecute, C>
Sourcepub fn send(self, message: &BackendMessage) -> Result<(Self, Frame)>
pub fn send(self, message: &BackendMessage) -> Result<(Self, Frame)>
Sends a non-terminal result message for Execute.
§Errors
Returns an error if the message cannot be reconstructed or requires a dedicated state transition.
Sourcepub fn command_complete(
self,
tag: Bytes,
) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
pub fn command_complete( self, tag: Bytes, ) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
Completes execution and returns to the building loop.
§Errors
Returns an error if the command tag contains a NUL byte.
Sourcepub fn portal_suspended(self) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
pub fn portal_suspended(self) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
Suspends a portal and returns to the building loop.
§Errors
Returns an error only if the fixed response cannot be encoded.
Sourcepub fn error(
self,
response: DiagnosticResponse,
) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
pub fn error( self, response: DiagnosticResponse, ) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
Rejects Execute and begins discarding the pipeline until Sync.
§Errors
Returns an error if a diagnostic field is invalid.
Sourcepub fn copy_in(self, response: CopyResponse) -> CopyInStart<S, C, CopyExtended>
pub fn copy_in(self, response: CopyResponse) -> CopyInStart<S, C, CopyExtended>
Starts an extended-query COPY IN sub-session.
§Errors
Returns an error if the format count overflows the protocol field.
Sourcepub fn copy_out(
self,
response: CopyResponse,
) -> CopyOutStart<S, C, CopyExtended>
pub fn copy_out( self, response: CopyResponse, ) -> CopyOutStart<S, C, CopyExtended>
Starts an extended-query COPY OUT sub-session.
§Errors
Returns an error if the format count overflows the protocol field.
Sourcepub fn copy_both(
self,
response: CopyResponse,
) -> CopyBothStart<S, C, CopyExtended>
pub fn copy_both( self, response: CopyResponse, ) -> CopyBothStart<S, C, CopyExtended>
Starts an extended-query COPY BOTH sub-session.
§Errors
Returns an error if the format count overflows the protocol field.
Source§impl<S, C> Conn<S, ServerCopyIn<CopySimple>, C>
impl<S, C> Conn<S, ServerCopyIn<CopySimple>, C>
Sourcepub fn offer_frontend(
self,
message: FrontendMessage,
) -> CopyInProjection<S, C, CopySimple>
pub fn offer_frontend( self, message: FrontendMessage, ) -> CopyInProjection<S, C, CopySimple>
Projects one inspected frontend message inside COPY IN.
§Errors
Returns the unchanged state and message for anything other than COPY data, completion, or failure.
Source§impl<S, C> Conn<S, ServerCopyIn<CopyExtended>, C>
impl<S, C> Conn<S, ServerCopyIn<CopyExtended>, C>
Sourcepub fn offer_frontend(
self,
message: FrontendMessage,
) -> CopyInProjection<S, C, CopyExtended>
pub fn offer_frontend( self, message: FrontendMessage, ) -> CopyInProjection<S, C, CopyExtended>
Projects one inspected frontend message inside extended-query COPY IN.
§Errors
Returns the unchanged state and message for anything other than COPY data, completion, or failure.
Source§impl<S, C> Conn<S, ServerCopyInDone<CopySimple>, C>
impl<S, C> Conn<S, ServerCopyInDone<CopySimple>, C>
Sourcepub fn command_complete(
self,
tag: Bytes,
) -> Result<(Conn<S, ServerSimpleQuery, C>, Frame)>
pub fn command_complete( self, tag: Bytes, ) -> Result<(Conn<S, ServerSimpleQuery, C>, Frame)>
Completes simple-query COPY IN before ReadyForQuery.
§Errors
Returns an error if the command tag contains a NUL byte.
Source§impl<S, C> Conn<S, ServerCopyInDone<CopyExtended>, C>
impl<S, C> Conn<S, ServerCopyInDone<CopyExtended>, C>
Sourcepub fn command_complete(
self,
tag: Bytes,
) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
pub fn command_complete( self, tag: Bytes, ) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
Completes extended-query COPY IN and returns to the building loop.
§Errors
Returns an error if the command tag contains a NUL byte.
Source§impl<S, C> Conn<S, ServerCopyInFailed<CopySimple>, C>
impl<S, C> Conn<S, ServerCopyInFailed<CopySimple>, C>
Sourcepub fn error(
self,
response: DiagnosticResponse,
) -> Result<(Conn<S, ServerSimpleError, C>, Frame)>
pub fn error( self, response: DiagnosticResponse, ) -> Result<(Conn<S, ServerSimpleError, C>, Frame)>
Reports a client COPY failure before simple-query readiness.
§Errors
Returns an error if a diagnostic field is invalid.
Source§impl<S, C> Conn<S, ServerCopyInFailed<CopyExtended>, C>
impl<S, C> Conn<S, ServerCopyInFailed<CopyExtended>, C>
Sourcepub fn error(
self,
response: DiagnosticResponse,
) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
pub fn error( self, response: DiagnosticResponse, ) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
Reports a client COPY failure and discards the pipeline until Sync.
§Errors
Returns an error if a diagnostic field is invalid.
Source§impl<S, C, Resume> Conn<S, ServerCopyOut<Resume>, C>
impl<S, C, Resume> Conn<S, ServerCopyOut<Resume>, C>
Sourcepub fn data(self, data: Bytes) -> Result<(Self, Frame)>
pub fn data(self, data: Bytes) -> Result<(Self, Frame)>
Sends one COPY OUT data chunk and remains in the nested session.
§Errors
Returns an error only if the data frame cannot be encoded.
Sourcepub fn replication(self, message: &BackendReplication) -> Result<(Self, Frame)>
pub fn replication(self, message: &BackendReplication) -> Result<(Self, Frame)>
Sends a structured WAL or keepalive payload.
§Errors
Returns an error only if the data frame cannot be encoded.
Sourcepub fn done(self) -> CopyOutCompletion<S, C, Resume>
pub fn done(self) -> CopyOutCompletion<S, C, Resume>
Ends the COPY data stream before its command completion.
§Errors
Returns an error only if the fixed response cannot be encoded.
Source§impl<S, C> Conn<S, ServerCopyOutDone<CopySimple>, C>
impl<S, C> Conn<S, ServerCopyOutDone<CopySimple>, C>
Sourcepub fn command_complete(
self,
tag: Bytes,
) -> Result<(Conn<S, ServerSimpleQuery, C>, Frame)>
pub fn command_complete( self, tag: Bytes, ) -> Result<(Conn<S, ServerSimpleQuery, C>, Frame)>
Completes simple-query COPY OUT before ReadyForQuery.
§Errors
Returns an error if the command tag contains a NUL byte.
Source§impl<S, C> Conn<S, ServerCopyOutDone<CopyExtended>, C>
impl<S, C> Conn<S, ServerCopyOutDone<CopyExtended>, C>
Sourcepub fn command_complete(
self,
tag: Bytes,
) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
pub fn command_complete( self, tag: Bytes, ) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
Completes extended-query COPY OUT and returns to the building loop.
§Errors
Returns an error if the command tag contains a NUL byte.
Source§impl<S, C, Resume: CopyResume> Conn<S, ServerCopyBoth<Resume, BothOpen>, C>
impl<S, C, Resume: CopyResume> Conn<S, ServerCopyBoth<Resume, BothOpen>, C>
Sourcepub fn offer_frontend(
self,
message: FrontendMessage,
) -> CopyBothOpenProjection<S, C, Resume>
pub fn offer_frontend( self, message: FrontendMessage, ) -> CopyBothOpenProjection<S, C, Resume>
Projects client data, half-close, or failure while both directions are open.
§Errors
Returns the unchanged state and message if it is not COPY traffic.
Sourcepub fn data(self, data: Bytes) -> Result<(Self, Frame)>
pub fn data(self, data: Bytes) -> Result<(Self, Frame)>
Sends backend COPY data while its direction remains open.
§Errors
Returns an error only if the data frame cannot be encoded.
Sourcepub fn replication(self, message: &BackendReplication) -> Result<(Self, Frame)>
pub fn replication(self, message: &BackendReplication) -> Result<(Self, Frame)>
Sends a structured WAL or keepalive payload while both halves are open.
§Errors
Returns an error only if the data frame cannot be encoded.
Sourcepub fn done(self) -> CopyBothServerHalfClose<S, C, Resume>
pub fn done(self) -> CopyBothServerHalfClose<S, C, Resume>
Half-closes the backend direction while the client direction remains open.
§Errors
Returns an error only if the fixed completion frame cannot be encoded.
Source§impl<S, C, Resume> Conn<S, ServerCopyBoth<Resume, BothClientDone>, C>
impl<S, C, Resume> Conn<S, ServerCopyBoth<Resume, BothClientDone>, C>
Sourcepub fn data(self, data: Bytes) -> Result<(Self, Frame)>
pub fn data(self, data: Bytes) -> Result<(Self, Frame)>
Sends remaining backend data after the client has half-closed.
§Errors
Returns an error only if the data frame cannot be encoded.
Sourcepub fn replication(self, message: &BackendReplication) -> Result<(Self, Frame)>
pub fn replication(self, message: &BackendReplication) -> Result<(Self, Frame)>
Sends a structured WAL or keepalive payload after the client half-close.
§Errors
Returns an error only if the data frame cannot be encoded.
Sourcepub fn done(self) -> CopyBothCompletion<S, C, Resume>
pub fn done(self) -> CopyBothCompletion<S, C, Resume>
Half-closes the backend direction, completing both COPY streams.
§Errors
Returns an error only if the fixed completion frame cannot be encoded.
Source§impl<S, C, Resume: CopyResume> Conn<S, ServerCopyBoth<Resume, BothServerDone>, C>
impl<S, C, Resume: CopyResume> Conn<S, ServerCopyBoth<Resume, BothServerDone>, C>
Sourcepub fn offer_frontend(
self,
message: FrontendMessage,
) -> CopyBothServerDoneProjection<S, C, Resume>
pub fn offer_frontend( self, message: FrontendMessage, ) -> CopyBothServerDoneProjection<S, C, Resume>
Projects remaining client traffic after the backend has half-closed.
§Errors
Returns the unchanged state and message if it is not COPY traffic.
Source§impl<S, C> Conn<S, ServerCopyBoth<CopySimple, BothDone>, C>
impl<S, C> Conn<S, ServerCopyBoth<CopySimple, BothDone>, C>
Sourcepub fn command_complete(
self,
tag: Bytes,
) -> Result<(Conn<S, ServerSimpleQuery, C>, Frame)>
pub fn command_complete( self, tag: Bytes, ) -> Result<(Conn<S, ServerSimpleQuery, C>, Frame)>
Completes simple-query COPY BOTH before ReadyForQuery.
§Errors
Returns an error if the command tag contains a NUL byte.
Source§impl<S, C> Conn<S, ServerCopyBoth<CopyExtended, BothDone>, C>
impl<S, C> Conn<S, ServerCopyBoth<CopyExtended, BothDone>, C>
Sourcepub fn command_complete(
self,
tag: Bytes,
) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
pub fn command_complete( self, tag: Bytes, ) -> Result<(Conn<S, ServerBuilding, C>, Frame)>
Completes extended-query COPY BOTH and returns to the building loop.
§Errors
Returns an error if the command tag contains a NUL byte.
Source§impl<S, C> Conn<S, ServerCopyBothFailed<CopySimple>, C>
impl<S, C> Conn<S, ServerCopyBothFailed<CopySimple>, C>
Sourcepub fn error(
self,
response: DiagnosticResponse,
) -> Result<(Conn<S, ServerSimpleError, C>, Frame)>
pub fn error( self, response: DiagnosticResponse, ) -> Result<(Conn<S, ServerSimpleError, C>, Frame)>
Reports a client COPY failure before simple-query readiness.
§Errors
Returns an error if a diagnostic field is invalid.
Source§impl<S, C> Conn<S, ServerCopyBothFailed<CopyExtended>, C>
impl<S, C> Conn<S, ServerCopyBothFailed<CopyExtended>, C>
Sourcepub fn error(
self,
response: DiagnosticResponse,
) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
pub fn error( self, response: DiagnosticResponse, ) -> Result<(Conn<S, ServerExtendedError, C>, Frame)>
Reports a client COPY failure and discards the pipeline until Sync.
§Errors
Returns an error if a diagnostic field is invalid.
Source§impl<S, C> Conn<S, ServerExtendedError, C>
impl<S, C> Conn<S, ServerExtendedError, C>
Sourcepub fn discard(self, message: &FrontendMessage) -> ServerDiscard<S, C>
pub fn discard(self, message: &FrontendMessage) -> ServerDiscard<S, C>
Discards one pipelined message; only Sync exits error recovery.
Source§impl<S, C> Conn<S, ServerSync, C>
impl<S, C> Conn<S, ServerSync, C>
Sourcepub fn ready(
self,
status: TransactionStatus,
) -> Result<(ServerReadyState<S, C>, Frame)>
pub fn ready( self, status: TransactionStatus, ) -> Result<(ServerReadyState<S, C>, Frame)>
Answers Sync with ReadyForQuery and surfaces transaction status.
§Errors
Returns an error only if the fixed ready message cannot be encoded.
Source§impl<S, C> Conn<S, Ready, C>
impl<S, C> Conn<S, Ready, C>
Sourcepub fn push_terminate(self) -> (Conn<S, Terminated, C>, Frame)
pub fn push_terminate(self) -> (Conn<S, Terminated, C>, Frame)
Gracefully terminates a ready session without waiting for a backend reply.
Sourcepub fn push_query(
self,
query: &[u8],
) -> Result<(Conn<S, SimpleQuery, Dirty>, Frame)>
pub fn push_query( self, query: &[u8], ) -> Result<(Conn<S, SimpleQuery, Dirty>, Frame)>
Buffers a simple query and conservatively taints the pooled session.
Simple-query text can create resources which are not reflected in
ParameterStatus, including listeners, prepared statements, and
advisory locks. Use Self::push_stateless_query only after custom SQL
inspection has established that the command cannot retain session state.
§Errors
Returns an error if the query contains a NUL byte.
Sourcepub fn push_stateless_query(
self,
query: &[u8],
) -> Result<(Conn<S, SimpleQuery, C>, Frame)>
pub fn push_stateless_query( self, query: &[u8], ) -> Result<(Conn<S, SimpleQuery, C>, Frame)>
Buffers query text which the caller has proved leaves no session state.
§Errors
Returns an error if the query contains a NUL byte.
Sourcepub fn push_function_call(
self,
message: &FunctionCall,
) -> Result<(Conn<S, FunctionCalling, Dirty>, Frame)>
pub fn push_function_call( self, message: &FunctionCall, ) -> Result<(Conn<S, FunctionCalling, Dirty>, Frame)>
Buffers the deprecated function-call protocol message as a typed exchange.
§Errors
Returns an error if a count or argument length exceeds its wire field.
Sourcepub fn push_stateless_function_call(
self,
message: &FunctionCall,
) -> Result<(Conn<S, FunctionCalling, C>, Frame)>
pub fn push_stateless_function_call( self, message: &FunctionCall, ) -> Result<(Conn<S, FunctionCalling, C>, Frame)>
Buffers an allow-listed function call known not to retain session state.
§Errors
Returns an error if a count or argument length exceeds its wire field.
Sourcepub fn begin_extended(self) -> Conn<S, Building, C>
pub fn begin_extended(self) -> Conn<S, Building, C>
Begins extended-query construction and consumes the ready connection.
use pg_proto::{Conn, auth::Ready};
fn use_after_transition<S, C>(conn: Conn<S, Ready, C>) {
let _building = conn.begin_extended();
let _again = conn.begin_extended();
}Source§impl<S, C> Conn<S, FunctionCalling, C>
impl<S, C> Conn<S, FunctionCalling, C>
Sourcepub fn offer(
self,
message: BackendMessage,
) -> Result<FunctionCallTransition<S, C>, (Self, BackendMessage)>
pub fn offer( self, message: BackendMessage, ) -> Result<FunctionCallTransition<S, C>, (Self, BackendMessage)>
Accepts exactly the function result or an error, after which readiness must still be consumed.
§Errors
Returns the unchanged connection and message for an illegal response.
Source§impl<S> Conn<S, Ready, Dirty>
impl<S> Conn<S, Ready, Dirty>
Sourcepub fn begin_reset(self) -> Result<(Conn<S, Resetting, Dirty>, Frame)>
pub fn begin_reset(self) -> Result<(Conn<S, Resetting, Dirty>, Frame)>
Begins the only typed path which can recover pool-safe cleanliness.
ROLLBACK makes the sequence legal after either transaction status;
DISCARD ALL then clears session-local resources and settings.
§Errors
Returns an error only if the fixed reset query cannot be encoded.
Source§impl<S, C> Conn<S, Building, C>
impl<S, C> Conn<S, Building, C>
Sourcepub fn push_parse(
self,
message: &Parse,
) -> Result<(Conn<S, Building, Dirty>, Frame)>
pub fn push_parse( self, message: &Parse, ) -> Result<(Conn<S, Building, Dirty>, Frame)>
Parse is a self-loop while constructing an extended-query pipeline.
§Errors
Returns an error if the structured message cannot be reconstructed.
Sourcepub fn push_describe(self, message: &Describe) -> Result<(Self, Frame)>
pub fn push_describe(self, message: &Describe) -> Result<(Self, Frame)>
Describe is a self-loop while constructing an extended-query pipeline.
§Errors
Returns an error if the structured message cannot be reconstructed.
Sourcepub fn push_bind(
self,
message: &Bind,
) -> Result<(Conn<S, BoundBuilding, Dirty>, Frame)>
pub fn push_bind( self, message: &Bind, ) -> Result<(Conn<S, BoundBuilding, Dirty>, Frame)>
Bind introduces an executable portal.
Execute is not available before this transition:
use bytes::Bytes;
use pg_proto::{Conn, session::Building};
fn execute_without_bind<S, C>(conn: Conn<S, Building, C>) {
let _ = conn.push_execute(Bytes::new());
}§Errors
Returns an error if the structured message cannot be reconstructed.
Sourcepub fn push_close(self, message: &Close) -> Result<(Self, Frame)>
pub fn push_close(self, message: &Close) -> Result<(Self, Frame)>
Close is legal while building, but does not make a portal executable.
§Errors
Returns an error if the structured message cannot be reconstructed.
Sourcepub fn push_flush(self) -> (Self, Frame)
pub fn push_flush(self) -> (Self, Frame)
Requests delivery of buffered extended-query responses without ending the cycle.
Sourcepub fn push_sync(self) -> (Conn<S, AwaitingReady, C>, Frame)
pub fn push_sync(self) -> (Conn<S, AwaitingReady, C>, Frame)
Ends the extended-query pipeline and waits for readiness.
Source§impl<S, C> Conn<S, BoundBuilding, C>
impl<S, C> Conn<S, BoundBuilding, C>
Sourcepub fn push_parse(
self,
message: &Parse,
) -> Result<(Conn<S, BoundBuilding, Dirty>, Frame)>
pub fn push_parse( self, message: &Parse, ) -> Result<(Conn<S, BoundBuilding, Dirty>, Frame)>
§Errors
Returns an error if the structured message cannot be reconstructed.
Sourcepub fn push_bind(
self,
message: &Bind,
) -> Result<(Conn<S, BoundBuilding, Dirty>, Frame)>
pub fn push_bind( self, message: &Bind, ) -> Result<(Conn<S, BoundBuilding, Dirty>, Frame)>
§Errors
Returns an error if the structured message cannot be reconstructed.
Sourcepub fn push_describe(self, message: &Describe) -> Result<(Self, Frame)>
pub fn push_describe(self, message: &Describe) -> Result<(Self, Frame)>
§Errors
Returns an error if the structured message cannot be reconstructed.
Sourcepub fn push_execute(self, message: &Execute) -> Result<(Self, Frame)>
pub fn push_execute(self, message: &Execute) -> Result<(Self, Frame)>
Execute is unavailable until a Bind transition has occurred.
§Errors
Returns an error if the structured message cannot be reconstructed.
Sourcepub fn push_close(self, message: &Close) -> Result<(Self, Frame)>
pub fn push_close(self, message: &Close) -> Result<(Self, Frame)>
§Errors
Returns an error if the structured message cannot be reconstructed.
Sourcepub fn push_flush(self) -> (Self, Frame)
pub fn push_flush(self) -> (Self, Frame)
Requests delivery of buffered extended-query responses without ending the cycle.
Sourcepub fn push_sync(self) -> (Conn<S, AwaitingReady, C>, Frame)
pub fn push_sync(self) -> (Conn<S, AwaitingReady, C>, Frame)
Ends the extended-query pipeline and waits for readiness.
Source§impl<S, C> Conn<S, SimpleQuery, C>
impl<S, C> Conn<S, SimpleQuery, C>
Sourcepub fn offer(
self,
item: SessionItem,
) -> Result<SimpleTransition<S, C>, (Self, SessionItem)>
pub fn offer( self, item: SessionItem, ) -> Result<SimpleTransition<S, C>, (Self, SessionItem)>
Advances a simple-query session using an actual projected backend item.
§Errors
Returns the unchanged connection and item if it is illegal in this phase.
Source§impl<S, C> Conn<S, CopyIn, C>
impl<S, C> Conn<S, CopyIn, C>
Sourcepub fn push_copy_data(self, data: Bytes) -> (Self, Frame)
pub fn push_copy_data(self, data: Bytes) -> (Self, Frame)
Query is unavailable in this nested COPY session.
use pg_proto::{Conn, session::CopyIn};
fn query_during_copy<S, C>(conn: Conn<S, CopyIn, C>) {
let _ = conn.push_query(b"select 1");
}Sourcepub fn push_copy_done(self) -> (Conn<S, AwaitingReady, C>, Frame)
pub fn push_copy_done(self) -> (Conn<S, AwaitingReady, C>, Frame)
Closes the client-to-backend copy stream and waits for command completion.
Sourcepub fn push_copy_fail(
self,
message: &[u8],
) -> Result<(Conn<S, AwaitingReady, C>, Frame)>
pub fn push_copy_fail( self, message: &[u8], ) -> Result<(Conn<S, AwaitingReady, C>, Frame)>
Aborts COPY IN with a frontend error string.
§Errors
Returns an error if the message contains a NUL byte.
Sourcepub fn offer(
self,
item: SessionItem,
) -> Result<CopyInTransition<S, C>, (Self, SessionItem)>
pub fn offer( self, item: SessionItem, ) -> Result<CopyInTransition<S, C>, (Self, SessionItem)>
Projects an asynchronous backend failure while COPY IN data is being sent.
This branch is reachable after cancellation or an early server-side COPY failure. Non-error messages leave the COPY IN connection unchanged.
§Errors
Returns the live connection and item when it is not an error response.
Source§impl<S, C> Conn<S, CopyBothClientDone, C>
impl<S, C> Conn<S, CopyBothClientDone, C>
Sourcepub fn offer(
self,
item: SessionItem,
) -> Result<CopyBothClientDoneReceive<S, C>, (Self, SessionItem)>
pub fn offer( self, item: SessionItem, ) -> Result<CopyBothClientDoneReceive<S, C>, (Self, SessionItem)>
Continues receiving after the frontend half has closed.
§Errors
Returns the unchanged connection and item for an illegal response.
Source§impl<S, C> Conn<S, CopyBothServerDone, C>
impl<S, C> Conn<S, CopyBothServerDone, C>
Sourcepub fn push_copy_data(self, data: Bytes) -> (Self, Frame)
pub fn push_copy_data(self, data: Bytes) -> (Self, Frame)
Continues sending after the backend half has closed.
Sourcepub fn push_replication(self, message: &FrontendReplication) -> (Self, Frame)
pub fn push_replication(self, message: &FrontendReplication) -> (Self, Frame)
Sends a structured standby message after the backend half-close.
Sourcepub fn push_copy_done(self) -> (Conn<S, AwaitingReady, C>, Frame)
pub fn push_copy_done(self) -> (Conn<S, AwaitingReady, C>, Frame)
Closes the remaining frontend half and begins readiness processing.
Source§impl<S, C> Conn<S, CopyOut, C>
impl<S, C> Conn<S, CopyOut, C>
Sourcepub fn offer(
self,
item: SessionItem,
) -> Result<CopyOutTransition<S, C>, (Self, SessionItem)>
pub fn offer( self, item: SessionItem, ) -> Result<CopyOutTransition<S, C>, (Self, SessionItem)>
Advances COPY OUT using backend evidence.
§Errors
Returns the unchanged connection and item when it is illegal in COPY OUT.
Source§impl<S, C> Conn<S, CopyBoth, C>
impl<S, C> Conn<S, CopyBoth, C>
Sourcepub fn push_copy_data(self, data: Bytes) -> (Self, Frame)
pub fn push_copy_data(self, data: Bytes) -> (Self, Frame)
Sends one opaque data chunk while retaining both COPY directions.
Sourcepub fn push_replication(self, message: &FrontendReplication) -> (Self, Frame)
pub fn push_replication(self, message: &FrontendReplication) -> (Self, Frame)
Sends a structured standby message in the walsender stream.
Sourcepub fn push_copy_done(self) -> (Conn<S, CopyBothClientDone, C>, Frame)
pub fn push_copy_done(self) -> (Conn<S, CopyBothClientDone, C>, Frame)
Closes the client half while leaving the backend half readable.
Sourcepub fn offer(
self,
item: SessionItem,
) -> Result<CopyBothReceive<S, C>, (Self, SessionItem)>
pub fn offer( self, item: SessionItem, ) -> Result<CopyBothReceive<S, C>, (Self, SessionItem)>
Receives the backend half of a bidirectional COPY session.
§Errors
Returns the unchanged connection and item when it is illegal in COPY BOTH.
Source§impl<S, C> Conn<S, Draining, C>
impl<S, C> Conn<S, Draining, C>
Sourcepub fn offer(self, item: SessionItem) -> DrainingTransition<S, C>
pub fn offer(self, item: SessionItem) -> DrainingTransition<S, C>
ReadyForQuery is the sole exit from error draining.
Source§impl<S, C> Conn<S, AwaitingReady, C>
impl<S, C> Conn<S, AwaitingReady, C>
Sourcepub fn offer(self, item: SessionItem) -> AwaitingReadyTransition<S, C>
pub fn offer(self, item: SessionItem) -> AwaitingReadyTransition<S, C>
Consumes responses after Sync until ReadyForQuery proves readiness.
Source§impl<S> Conn<S, Resetting, Dirty>
impl<S> Conn<S, Resetting, Dirty>
Sourcepub fn offer(self, item: SessionItem) -> ResettingTransition<S>
pub fn offer(self, item: SessionItem) -> ResettingTransition<S>
Waits for evidence that DISCARD ALL itself completed.
Source§impl<S> Conn<S, ResetComplete, Dirty>
impl<S> Conn<S, ResetComplete, Dirty>
Sourcepub fn offer(self, item: SessionItem) -> ResetCompleteTransition<S>
pub fn offer(self, item: SessionItem) -> ResetCompleteTransition<S>
Restores Pristine only from idle readiness and the startup parameter baseline.
Source§impl<S, P> Conn<S, P, Pristine>
impl<S, P> Conn<S, P, Pristine>
Sourcepub fn mark_dirty(self) -> Conn<S, P, Dirty>
pub fn mark_dirty(self) -> Conn<S, P, Dirty>
Conservatively records session-local state without changing protocol phase.
Source§impl<S, D, Phase, Cleanliness> Conn<Buffered<S, D>, Phase, Cleanliness>
impl<S, D, Phase, Cleanliness> Conn<Buffered<S, D>, Phase, Cleanliness>
Sourcepub fn push_frame(&mut self, frame: Frame) -> Result<()>
pub fn push_frame(&mut self, frame: Frame) -> Result<()>
Adds an already-typed message to this connection’s outbound buffer.
§Errors
Returns an error when the frame is too large to encode.
Sourcepub fn pending_output(&self) -> &[u8] ⓘ
pub fn pending_output(&self) -> &[u8] ⓘ
Returns encoded output which has not yet been flushed.
Source§impl<S, Cleanliness> Conn<Buffered<S, Backend>, PreStartup, Cleanliness>
impl<S, Cleanliness> Conn<Buffered<S, Backend>, PreStartup, Cleanliness>
Sourcepub fn request_ssl(
self,
) -> Conn<Buffered<S, Backend>, AwaitingSslReply, Cleanliness>
pub fn request_ssl( self, ) -> Conn<Buffered<S, Backend>, AwaitingSslReply, Cleanliness>
Buffers an SSLRequest and enters the raw single-byte reply phase.
Sourcepub fn request_gss(
self,
) -> Conn<Buffered<S, Backend>, AwaitingGssReply, Cleanliness>
pub fn request_gss( self, ) -> Conn<Buffered<S, Backend>, AwaitingGssReply, Cleanliness>
Buffers a GSSENCRequest and enters the raw single-byte reply phase.
Source§impl<S, Cleanliness> Conn<Buffered<S, Frontend>, ServerSslDecision, Cleanliness>
impl<S, Cleanliness> Conn<Buffered<S, Frontend>, ServerSslDecision, Cleanliness>
Sourcepub fn approve_ssl(
self,
) -> Conn<Buffered<S, Frontend>, TlsHandshake, Cleanliness>
pub fn approve_ssl( self, ) -> Conn<Buffered<S, Frontend>, TlsHandshake, Cleanliness>
Buffers the server’s raw S response and enters the TLS handshake phase.
Sourcepub fn decline_ssl(self) -> Conn<Buffered<S, Frontend>, PreStartup, Cleanliness>
pub fn decline_ssl(self) -> Conn<Buffered<S, Frontend>, PreStartup, Cleanliness>
Buffers the server’s raw N response and returns to pre-startup choice.
Sourcepub fn reject_ssl_with_legacy_error(
self,
) -> Conn<Buffered<S, Frontend>, Terminated, Cleanliness>
pub fn reject_ssl_with_legacy_error( self, ) -> Conn<Buffered<S, Frontend>, Terminated, Cleanliness>
Buffers the historical raw E response and terminates negotiation.
Source§impl<S, Cleanliness> Conn<Buffered<S, Frontend>, ServerGssDecision, Cleanliness>
impl<S, Cleanliness> Conn<Buffered<S, Frontend>, ServerGssDecision, Cleanliness>
Sourcepub fn approve_gss(
self,
) -> Conn<Buffered<S, Frontend>, GssHandshake, Cleanliness>
pub fn approve_gss( self, ) -> Conn<Buffered<S, Frontend>, GssHandshake, Cleanliness>
Buffers the server’s raw S response and enters the GSS handshake phase.
Sourcepub fn decline_gss(self) -> Conn<Buffered<S, Frontend>, PreStartup, Cleanliness>
pub fn decline_gss(self) -> Conn<Buffered<S, Frontend>, PreStartup, Cleanliness>
Buffers the server’s raw N response and returns to pre-startup choice.
Sourcepub fn reject_gss_with_legacy_error(
self,
) -> Conn<Buffered<S, Frontend>, Terminated, Cleanliness>
pub fn reject_gss_with_legacy_error( self, ) -> Conn<Buffered<S, Frontend>, Terminated, Cleanliness>
Buffers the historical raw E response and terminates negotiation.
Source§impl<S: AsyncRead + Unpin, Cleanliness> Conn<Buffered<S, Backend>, AwaitingSslReply, Cleanliness>
impl<S: AsyncRead + Unpin, Cleanliness> Conn<Buffered<S, Backend>, AwaitingSslReply, Cleanliness>
Sourcepub async fn receive_ssl_reply(
self,
) -> Result<Negotiation<Buffered<S, Backend>, TlsHandshake, Cleanliness>>
pub async fn receive_ssl_reply( self, ) -> Result<Negotiation<Buffered<S, Backend>, TlsHandshake, Cleanliness>>
Receives and projects the server’s raw SSL decision byte.
§Errors
Returns an I/O error or rejects a byte other than S, N, or E.
Sourcepub async fn receive_ssl_reply_for_mode(
self,
mode: SslMode,
) -> Result<SslModeNegotiation<Buffered<S, Backend>, Cleanliness>>
pub async fn receive_ssl_reply_for_mode( self, mode: SslMode, ) -> Result<SslModeNegotiation<Buffered<S, Backend>, Cleanliness>>
Receives the server decision and enforces the selected plaintext fallback policy.
§Errors
Returns an I/O error or rejects a byte other than S, N, or E.
Source§impl<S: AsyncRead + Unpin, Cleanliness> Conn<Buffered<S, Backend>, AwaitingGssReply, Cleanliness>
impl<S: AsyncRead + Unpin, Cleanliness> Conn<Buffered<S, Backend>, AwaitingGssReply, Cleanliness>
Sourcepub async fn receive_gss_reply(
self,
) -> Result<Negotiation<Buffered<S, Backend>, GssHandshake, Cleanliness>>
pub async fn receive_gss_reply( self, ) -> Result<Negotiation<Buffered<S, Backend>, GssHandshake, Cleanliness>>
Receives and projects the server’s raw GSSENC decision byte.
§Errors
Returns an I/O error or rejects a byte other than S, N, or E.
Source§impl<S, Cleanliness> Conn<Buffered<S, Backend>, TlsHandshake, Cleanliness>
impl<S, Cleanliness> Conn<Buffered<S, Backend>, TlsHandshake, Cleanliness>
Sourcepub async fn connect_tls(
self,
server_name: ServerName<'static>,
config: Arc<ClientConfig>,
) -> Result<Conn<Buffered<ClientTls<S>, Backend>, PreStartup, Cleanliness>>
pub async fn connect_tls( self, server_name: ServerName<'static>, config: Arc<ClientConfig>, ) -> Result<Conn<Buffered<ClientTls<S>, Backend>, PreStartup, Cleanliness>>
Completes a client-side TLS handshake and changes the transport type.
§Errors
Returns a TLS handshake, certificate, channel-binding, or buffer-state error.
Source§impl<S, Cleanliness> Conn<Buffered<S, Frontend>, TlsHandshake, Cleanliness>
impl<S, Cleanliness> Conn<Buffered<S, Frontend>, TlsHandshake, Cleanliness>
Sourcepub async fn accept_tls(
self,
config: Arc<ServerConfig>,
leaf_certificate: CertificateDer<'static>,
) -> Result<Conn<Buffered<ServerTls<S>, Frontend>, PreStartup, Cleanliness>>
pub async fn accept_tls( self, config: Arc<ServerConfig>, leaf_certificate: CertificateDer<'static>, ) -> Result<Conn<Buffered<ServerTls<S>, Frontend>, PreStartup, Cleanliness>>
Completes a server-side TLS handshake and changes the transport type.
§Errors
Returns a TLS handshake, certificate, channel-binding, or buffer-state error.
Source§impl<S, D, Cleanliness> Conn<Buffered<S, D>, Startup, Cleanliness>
impl<S, D, Cleanliness> Conn<Buffered<S, D>, Startup, Cleanliness>
Sourcepub fn push_startup_packet(&mut self, packet: &[u8])
pub fn push_startup_packet(&mut self, packet: &[u8])
Buffers the raw, untagged startup packet before normal framing begins.
Source§impl<S: AsyncRead + Unpin, Phase, Cleanliness> Conn<Buffered<S, Backend>, Phase, Cleanliness>
impl<S: AsyncRead + Unpin, Phase, Cleanliness> Conn<Buffered<S, Backend>, Phase, Cleanliness>
Sourcepub async fn receive_backend_wire(&mut self) -> Result<BackendMessage>
pub async fn receive_backend_wire(&mut self) -> Result<BackendMessage>
Receives one backend message before demultiplexing or state advancement. This is the interception point for proxy policy and message rewriting.
§Errors
Returns decoding and underlying transport read errors, or UnexpectedEof.
Sourcepub fn project_backend(
&mut self,
message: BackendMessage,
) -> Option<SessionItem>
pub fn project_backend( &mut self, message: BackendMessage, ) -> Option<SessionItem>
Projects an inspected or modified message into the filtered session stream.
Sourcepub async fn receive(&mut self) -> Result<SessionItem>
pub async fn receive(&mut self) -> Result<SessionItem>
Receives the next message in the filtered session projection.
§Errors
Returns decoding and underlying transport read errors, or UnexpectedEof.
Sourcepub fn cancel_key(&self) -> Option<&CancelKey>
pub fn cancel_key(&self) -> Option<&CancelKey>
Returns the latest upstream cancellation key observed during startup.
Sourcepub fn parameters(&self) -> &BTreeMap<Bytes, Bytes>
pub fn parameters(&self) -> &BTreeMap<Bytes, Bytes>
Returns the latest backend parameter values observed by the demux.
Sourcepub fn parameters_changed(&self) -> bool
pub fn parameters_changed(&self) -> bool
Returns whether current parameters differ from the startup baseline.
Sourcepub fn transaction_status(&self) -> Option<TransactionStatus>
pub fn transaction_status(&self) -> Option<TransactionStatus>
Returns the latest transaction status observed in ReadyForQuery.
Sourcepub fn pop_notification(&mut self) -> Option<Notification>
pub fn pop_notification(&mut self) -> Option<Notification>
Removes the oldest queued asynchronous notification.
Sourcepub fn pop_notice(&mut self) -> Option<TaggedNotice>
pub fn pop_notice(&mut self) -> Option<TaggedNotice>
Removes the next tagged notice for prompt forwarding to the client.
Sourcepub fn pop_parameter_status(&mut self) -> Option<ParameterStatus>
pub fn pop_parameter_status(&mut self) -> Option<ParameterStatus>
Removes the next ordered parameter update for forwarding to the client.
Sourcepub fn pop_async_event(&mut self) -> Option<OrderedAsyncEvent>
pub fn pop_async_event(&mut self) -> Option<OrderedAsyncEvent>
Removes the next independent backend event in original wire order.
Source§impl<S: AsyncRead + Unpin, Phase, Cleanliness> Conn<Buffered<S, Frontend>, Phase, Cleanliness>
impl<S: AsyncRead + Unpin, Phase, Cleanliness> Conn<Buffered<S, Frontend>, Phase, Cleanliness>
Sourcepub async fn receive_frontend_wire(&mut self) -> Result<FrontendMessage>
pub async fn receive_frontend_wire(&mut self) -> Result<FrontendMessage>
Receives one frontend message before any server-role state advancement.
§Errors
Returns decoding and underlying transport read errors, or UnexpectedEof.
Source§impl<S: AsyncRead + Unpin, Cleanliness> Conn<Buffered<S, Frontend>, PreStartup, Cleanliness>
impl<S: AsyncRead + Unpin, Cleanliness> Conn<Buffered<S, Frontend>, PreStartup, Cleanliness>
Sourcepub async fn receive_pre_startup_wire(&mut self) -> Result<PreStartupMessage>
pub async fn receive_pre_startup_wire(&mut self) -> Result<PreStartupMessage>
Receives a raw pre-startup packet before server-role state projection.
§Errors
Returns malformed pre-startup data and underlying transport read errors.
Source§impl<Transport, Phase, Cleanliness> Conn<Transport, Phase, Cleanliness>
impl<Transport, Phase, Cleanliness> Conn<Transport, Phase, Cleanliness>
Sourcepub fn into_transport(self) -> Transport
pub fn into_transport(self) -> Transport
Returns the underlying transport when deliberately leaving the typed API.
§Panics
Panics only if an internal transition has already moved the transport.
Sourcepub fn map_transport<Next>(
self,
map: impl FnOnce(Transport) -> Next,
) -> Conn<Next, Phase, Cleanliness>
pub fn map_transport<Next>( self, map: impl FnOnce(Transport) -> Next, ) -> Conn<Next, Phase, Cleanliness>
Changes transport representation without changing either state index.
§Panics
Panics only if an internal transition has already moved the transport.