pub enum DbStream {
Plain(TcpStream),
Tls(Box<TlsStream<TcpStream>>),
Closed,
}Expand description
A socket that may or may not have been upgraded.
An enum rather than a boxed trait object: there are exactly two cases, both
known at compile time, and a virtual call per read on a database connection
buys nothing. Closed exists for the instant during the handshake when the
plain socket has been taken out and the encrypted one is not yet in — a real
placeholder, so a bug there reports itself instead of hanging on a dead file
descriptor.
Variants§
Implementations§
Source§impl DbStream
impl DbStream
pub fn is_encrypted(&self) -> bool
Sourcepub fn take_plain(&mut self) -> Result<TcpStream>
pub fn take_plain(&mut self) -> Result<TcpStream>
Take the plain socket out, leaving Closed behind.
Only for the upgrade: a driver calls this, hands the socket to
upgrade, and puts the result back.
pub async fn write_all(&mut self, bytes: &[u8]) -> Result<()>
pub async fn flush(&mut self) -> Result<()>
pub async fn read(&mut self, buffer: &mut [u8]) -> Result<usize>
pub async fn shutdown(&mut self) -> Result<()>
Auto Trait Implementations§
impl !Freeze for DbStream
impl !RefUnwindSafe for DbStream
impl !UnwindSafe for DbStream
impl Send for DbStream
impl Sync for DbStream
impl Unpin for DbStream
impl UnsafeUnpin for DbStream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more