Struct TcpStream

Source
pub struct TcpStream(/* private fields */);

Implementations§

Source§

impl TcpStream

Source

pub fn connect(addr: &SocketAddress) -> Result<Self>

Creates and connects a non-blocking TcpStream at the specified address, blocks until the connection is established.

§Errors

Various OS errors relating to permissions, and networking issues

Source

pub fn connect_with_timeout( addr: &SocketAddress, timeout: Duration, ) -> Result<Self>

Creates and connects a non-blocking TcpStream at the specified address with a connection timeout.

§Errors

Various OS errors relating to permissions, and networking issues

Source

pub fn try_connect(addr: &SocketAddress) -> Result<TcpTryConnect>

Attempts to connect a non-blocking TcpStream at the specified address, returns Some if a connection can be established immediately and None if it can’t.

§Errors

Various OS errors relating to permissions, and networking issues

Source

pub fn read_with_timeout( &mut self, buf: &mut [u8], timeout: Duration, ) -> Result<usize>

Reads from this socket, into the provided buffer, with the specified timeout

§Errors

Os-errors related to reads, or a timeout

Trait Implementations§

Source§

impl AsRawFd for TcpStream

Source§

impl Debug for TcpStream

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Read for TcpStream

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

Read into to provided buffer Read more
Source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>

Reads to the end of this Reader, Read more
Source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize>

Reads to the end of the provided buffer Read more
Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>

Reads exactly enough bytes to fill the buffer Read more
Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Get this reader by mut ref Read more
Source§

impl Write for TcpStream

Source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Tries to write the contents of the provided buffer into this writer returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes this Writer Read more
Source§

fn write_all(&mut self, buf: &[u8]) -> Result<()>

Writes the full buffer into this Writer Read more
Source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()>

Writes format arguments into this Writer Read more
Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Get this Writer as a mutable reference

Auto Trait Implementations§

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<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, 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.