pub struct Connection<I, O> { /* private fields */ }Expand description
Implementations§
Source§impl<I, O> Connection<I, O>
impl<I, O> Connection<I, O>
Sourcepub fn seize(stream: TcpStream) -> Self
pub fn seize(stream: TcpStream) -> Self
Creates a Connection that will take over the given net::TcpStream.
Unless you know what you are doing, use a Plug instead!
Sourcepub async fn write(&mut self, input: I) -> Result<()>where
I: Serialize,
pub async fn write(&mut self, input: I) -> Result<()>where
I: Serialize,
Writes the given input to the Connection.
Sourcepub async fn write_bytes(&mut self, input: &[u8]) -> Result<()>where
I: Serialize,
pub async fn write_bytes(&mut self, input: &[u8]) -> Result<()>where
I: Serialize,
Writes raw bytes to the Connection.
Sourcepub async fn read(&mut self) -> Result<O>where
O: DeserializeOwned,
pub async fn read(&mut self) -> Result<O>where
O: DeserializeOwned,
Reads some output from the Connection.
Sourcepub async fn read_bytes(&mut self) -> Result<&[u8]>
pub async fn read_bytes(&mut self) -> Result<&[u8]>
Reads raw bytes from the Connection.
Sourcepub async fn copy<T>(&mut self, to: &mut Connection<T, O>) -> Result<u64>
pub async fn copy<T>(&mut self, to: &mut Connection<T, O>) -> Result<u64>
Copies all the output of the Connection to the provided one, effectively
creating a proxy.
Sourcepub async fn connect<T>(
&mut self,
with: &mut Connection<T, O>,
) -> Result<(u64, u64)>
pub async fn connect<T>( &mut self, with: &mut Connection<T, O>, ) -> Result<(u64, u64)>
Connects this Connection with another, copying in both directions.
Trait Implementations§
Auto Trait Implementations§
impl<I, O> !Freeze for Connection<I, O>
impl<I, O> RefUnwindSafe for Connection<I, O>where
I: RefUnwindSafe,
O: RefUnwindSafe,
impl<I, O> Send for Connection<I, O>
impl<I, O> Sync for Connection<I, O>
impl<I, O> Unpin for Connection<I, O>
impl<I, O> UnwindSafe for Connection<I, O>where
I: UnwindSafe,
O: UnwindSafe,
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