[−][src]Struct pg_wire::HandShakeProcess
Encapsulate protocol hand shake process
Examples
ⓘThis example is not tested
use pg_wire::{HandShakeProcess, HandShakeStatus, HandShakeRequest}; let mut stream = accept_tcp_connection(); let mut process = HandShakeProcess::start(); let mut buffer: Option<Vec<u8>> = None; loop { match process.next_stage(buffer.as_deref()) { Ok(HandShakeStatus::Requesting(HandShakeRequest::Buffer(len))) => { let mut buf = vec![b'0'; len]; buffer = Some(stream.read(&mut buf)); } Ok(HandShakeStatus::Requesting(HandShakeRequest::UpgradeToSsl)) => { stream.write_all(&[b'S']); // accepting tls connection from client stream = tls_stream(stream); } Ok(HandShakeStatus::Cancel(conn_id, secret_key)) => { handle_request_cancellation(conn_id, secret_key); break; } Ok(HandShakeStatus::Done(props)) => { handle_authentication_and_other_stuff(); break; } Err(protocol_error) => { handle_protocol_error(protocol_error); break; } } }
Implementations
impl Process
[src]
pub fn start() -> Process
[src]
Creates new process to make client <-> server hand shake
pub fn next_stage(&mut self, payload: Option<&[u8]>) -> Result<Status>
[src]
Proceed to the next stage of client <-> server hand shake
Auto Trait Implementations
impl RefUnwindSafe for Process
impl Send for Process
impl Sync for Process
impl Unpin for Process
impl UnwindSafe for Process
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,