Movatterモバイル変換


[0]ホーム

URL:


TcpStream

std::net

StructTcpStream 

1.0.0 ·Source
pub struct TcpStream(/* private fields */);
Expand description

A TCP stream between a local and a remote socket.

After creating aTcpStream by eitherconnecting to a remote host oraccepting a connection on aTcpListener, data can be transmittedbyreading andwriting to it.

The connection will be closed when the value is dropped. The reading and writingportions of the connection can also be shut down individually with theshutdownmethod.

The Transmission Control Protocol is specified inIETF RFC 793.

§Examples

usestd::io::prelude::*;usestd::net::TcpStream;fnmain() -> std::io::Result<()> {letmutstream = TcpStream::connect("127.0.0.1:34254")?;    stream.write(&[1])?;    stream.read(&mut[0;128])?;Ok(())}// the stream is closed here

§Platform-specific Behavior

On Unix, writes to the underlying socket inSOCK_STREAM mode are made withMSG_NOSIGNAL flag. This suppresses the emission of theSIGPIPE signal when writingto disconnected socket. In some cases, getting aSIGPIPE would trigger process termination.

Implementations§

Source§

implTcpStream

1.0.0 ·Source

pub fnconnect<A:ToSocketAddrs>(addr: A) ->Result<TcpStream>

Opens a TCP connection to a remote host.

addr is an address of the remote host. Anything which implementsToSocketAddrs trait can be supplied for the address; see this traitdocumentation for concrete examples.

Ifaddr yields multiple addresses,connect will be attempted witheach of the addresses until a connection is successful. If none ofthe addresses result in a successful connection, the error returned fromthe last connection attempt (the last address) is returned.

§Examples

Open a TCP connection to127.0.0.1:8080:

usestd::net::TcpStream;if letOk(stream) = TcpStream::connect("127.0.0.1:8080") {println!("Connected to the server!");}else{println!("Couldn't connect to server...");}

Open a TCP connection to127.0.0.1:8080. If the connection fails, opena TCP connection to127.0.0.1:8081:

usestd::net::{SocketAddr, TcpStream};letaddrs = [    SocketAddr::from(([127,0,0,1],8080)),    SocketAddr::from(([127,0,0,1],8081)),];if letOk(stream) = TcpStream::connect(&addrs[..]) {println!("Connected to the server!");}else{println!("Couldn't connect to server...");}
1.21.0 ·Source

pub fnconnect_timeout( addr: &SocketAddr, timeout:Duration,) ->Result<TcpStream>

Opens a TCP connection to a remote host with a timeout.

Unlikeconnect,connect_timeout takes a singleSocketAddr sincetimeout must be applied to individual addresses.

It is an error to pass a zeroDuration to this function.

Unlike other methods onTcpStream, this does not correspond to asingle system call. It instead callsconnect in nonblocking mode andthen uses an OS-specific mechanism to await the completion of theconnection request.

1.0.0 ·Source

pub fnpeer_addr(&self) ->Result<SocketAddr>

Returns the socket address of the remote peer of this TCP connection.

§Examples
usestd::net::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpStream};letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");assert_eq!(stream.peer_addr().unwrap(),           SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127,0,0,1),8080)));
1.0.0 ·Source

pub fnlocal_addr(&self) ->Result<SocketAddr>

Returns the socket address of the local half of this TCP connection.

§Examples
usestd::net::{IpAddr, Ipv4Addr, TcpStream};letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");assert_eq!(stream.local_addr().unwrap().ip(),           IpAddr::V4(Ipv4Addr::new(127,0,0,1)));
1.0.0 ·Source

pub fnshutdown(&self, how:Shutdown) ->Result<()>

Shuts down the read, write, or both halves of this connection.

This function will cause all pending and future I/O on the specifiedportions to return immediately with an appropriate value (see thedocumentation ofShutdown).

§Platform-specific behavior

Calling this function multiple times may result in different behavior,depending on the operating system. On Linux, the second call willreturnOk(()), but on macOS, it will returnErrorKind::NotConnected.This may change in the future.

§Examples
usestd::net::{Shutdown, TcpStream};letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");stream.shutdown(Shutdown::Both).expect("shutdown call failed");
1.0.0 ·Source

pub fntry_clone(&self) ->Result<TcpStream>

Creates a new independently owned handle to the underlying socket.

The returnedTcpStream is a reference to the same stream that thisobject references. Both handles will read and write the same stream ofdata, and options set on one stream will be propagated to the otherstream.

§Examples
usestd::net::TcpStream;letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");letstream_clone = stream.try_clone().expect("clone failed...");
1.4.0 ·Source

pub fnset_read_timeout(&self, dur:Option<Duration>) ->Result<()>

Sets the read timeout to the timeout specified.

If the value specified isNone, thenread calls will blockindefinitely. AnErr is returned if the zeroDuration ispassed to this method.

§Platform-specific behavior

Platforms may return a different error code whenever a read times out asa result of setting this option. For example Unix typically returns anerror of the kindWouldBlock, but Windows may returnTimedOut.

§Examples
usestd::net::TcpStream;letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");stream.set_read_timeout(None).expect("set_read_timeout call failed");

AnErr is returned if the zeroDuration is passed to thismethod:

usestd::io;usestd::net::TcpStream;usestd::time::Duration;letstream = TcpStream::connect("127.0.0.1:8080").unwrap();letresult = stream.set_read_timeout(Some(Duration::new(0,0)));leterr = result.unwrap_err();assert_eq!(err.kind(), io::ErrorKind::InvalidInput)
1.4.0 ·Source

pub fnset_write_timeout(&self, dur:Option<Duration>) ->Result<()>

Sets the write timeout to the timeout specified.

If the value specified isNone, thenwrite calls will blockindefinitely. AnErr is returned if the zeroDuration ispassed to this method.

§Platform-specific behavior

Platforms may return a different error code whenever a write times outas a result of setting this option. For example Unix typically returnsan error of the kindWouldBlock, but Windows may returnTimedOut.

§Examples
usestd::net::TcpStream;letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");stream.set_write_timeout(None).expect("set_write_timeout call failed");

AnErr is returned if the zeroDuration is passed to thismethod:

usestd::io;usestd::net::TcpStream;usestd::time::Duration;letstream = TcpStream::connect("127.0.0.1:8080").unwrap();letresult = stream.set_write_timeout(Some(Duration::new(0,0)));leterr = result.unwrap_err();assert_eq!(err.kind(), io::ErrorKind::InvalidInput)
1.4.0 ·Source

pub fnread_timeout(&self) ->Result<Option<Duration>>

Returns the read timeout of this socket.

If the timeout isNone, thenread calls will block indefinitely.

§Platform-specific behavior

Some platforms do not provide access to the current timeout.

§Examples
usestd::net::TcpStream;letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");stream.set_read_timeout(None).expect("set_read_timeout call failed");assert_eq!(stream.read_timeout().unwrap(),None);
1.4.0 ·Source

pub fnwrite_timeout(&self) ->Result<Option<Duration>>

Returns the write timeout of this socket.

If the timeout isNone, thenwrite calls will block indefinitely.

§Platform-specific behavior

Some platforms do not provide access to the current timeout.

§Examples
usestd::net::TcpStream;letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");stream.set_write_timeout(None).expect("set_write_timeout call failed");assert_eq!(stream.write_timeout().unwrap(),None);
1.18.0 ·Source

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

Receives data on the socket from the remote address to which it isconnected, without removing that data from the queue. On success,returns the number of bytes peeked.

Successive calls return the same data. This is accomplished by passingMSG_PEEK as a flag to the underlyingrecv system call.

§Examples
usestd::net::TcpStream;letstream = TcpStream::connect("127.0.0.1:8000")                       .expect("Couldn't connect to the server...");letmutbuf = [0;10];letlen = stream.peek(&mutbuf).expect("peek failed");
Source

pub fnset_linger(&self, linger:Option<Duration>) ->Result<()>

🔬This is a nightly-only experimental API. (tcp_linger #88494)

Sets the value of theSO_LINGER option on this socket.

This value controls how the socket is closed when data remainsto be sent. IfSO_LINGER is set, the socket will remain openfor the specified duration as the system attempts to send pending data.Otherwise, the system may close the socket immediately, or wait for adefault timeout.

§Examples
#![feature(tcp_linger)]usestd::net::TcpStream;usestd::time::Duration;letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");stream.set_linger(Some(Duration::from_secs(0))).expect("set_linger call failed");
Source

pub fnlinger(&self) ->Result<Option<Duration>>

🔬This is a nightly-only experimental API. (tcp_linger #88494)

Gets the value of theSO_LINGER option on this socket.

For more information about this option, seeTcpStream::set_linger.

§Examples
#![feature(tcp_linger)]usestd::net::TcpStream;usestd::time::Duration;letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");stream.set_linger(Some(Duration::from_secs(0))).expect("set_linger call failed");assert_eq!(stream.linger().unwrap(),Some(Duration::from_secs(0)));
1.9.0 ·Source

pub fnset_nodelay(&self, nodelay:bool) ->Result<()>

Sets the value of theTCP_NODELAY option on this socket.

If set, this option disables the Nagle algorithm. This means thatsegments are always sent as soon as possible, even if there is only asmall amount of data. When not set, data is buffered until there is asufficient amount to send out, thereby avoiding the frequent sending ofsmall packets.

§Examples
usestd::net::TcpStream;letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");stream.set_nodelay(true).expect("set_nodelay call failed");
1.9.0 ·Source

pub fnnodelay(&self) ->Result<bool>

Gets the value of theTCP_NODELAY option on this socket.

For more information about this option, seeTcpStream::set_nodelay.

§Examples
usestd::net::TcpStream;letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");stream.set_nodelay(true).expect("set_nodelay call failed");assert_eq!(stream.nodelay().unwrap_or(false),true);
1.9.0 ·Source

pub fnset_ttl(&self, ttl:u32) ->Result<()>

Sets the value for theIP_TTL option on this socket.

This value sets the time-to-live field that is used in every packet sentfrom this socket.

§Examples
usestd::net::TcpStream;letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");stream.set_ttl(100).expect("set_ttl call failed");
1.9.0 ·Source

pub fnttl(&self) ->Result<u32>

Gets the value of theIP_TTL option for this socket.

For more information about this option, seeTcpStream::set_ttl.

§Examples
usestd::net::TcpStream;letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");stream.set_ttl(100).expect("set_ttl call failed");assert_eq!(stream.ttl().unwrap_or(0),100);
1.9.0 ·Source

pub fntake_error(&self) ->Result<Option<Error>>

Gets the value of theSO_ERROR option on this socket.

This will retrieve the stored error in the underlying socket, clearingthe field in the process. This can be useful for checking errors betweencalls.

§Examples
usestd::net::TcpStream;letstream = TcpStream::connect("127.0.0.1:8080")                       .expect("Couldn't connect to the server...");stream.take_error().expect("No error was expected...");
1.9.0 ·Source

pub fnset_nonblocking(&self, nonblocking:bool) ->Result<()>

Moves this TCP stream into or out of nonblocking mode.

This will result inread,write,recv andsend system operationsbecoming nonblocking, i.e., immediately returning from their calls.If the IO operation is successful,Ok is returned and no furtheraction is required. If the IO operation could not be completed and needsto be retried, an error with kindio::ErrorKind::WouldBlock isreturned.

On Unix platforms, calling this method corresponds to callingfcntlFIONBIO. On Windows calling this method corresponds to callingioctlsocketFIONBIO.

§Examples

Reading bytes from a TCP stream in non-blocking mode:

usestd::io::{self, Read};usestd::net::TcpStream;letmutstream = TcpStream::connect("127.0.0.1:7878")    .expect("Couldn't connect to the server...");stream.set_nonblocking(true).expect("set_nonblocking call failed");letmutbuf =vec![];loop{matchstream.read_to_end(&mutbuf) {Ok(_) =>break,Err(refe)ife.kind() == io::ErrorKind::WouldBlock => {// wait until network socket is ready, typically implemented            // via platform-specific APIs such as epoll or IOCPwait_for_fd();        }Err(e) =>panic!("encountered IO error: {e}"),    };};println!("bytes: {buf:?}");

Trait Implementations§

1.63.0 ·Source§

implAsFd forTcpStream

Available on(Unix or HermitCore ortarget_os=trusty or WASI ortarget_os=motor) and non-target_os=trusty only.
Source§

fnas_fd(&self) ->BorrowedFd<'_>

Borrows the file descriptor.Read more
1.0.0 ·Source§

implAsRawFd forTcpStream

Available onnon-target_os=trusty and (Unix or HermitCore ortarget_os=trusty or WASI ortarget_os=motor) only.
Source§

fnas_raw_fd(&self) ->RawFd

Extracts the raw file descriptor.Read more
1.0.0 ·Source§

implAsRawSocket forTcpStream

Available onWindows only.
Source§

fnas_raw_socket(&self) ->RawSocket

Extracts the raw socket.Read more
1.63.0 ·Source§

implAsSocket forTcpStream

Available onWindows only.
Source§

fnas_socket(&self) ->BorrowedSocket<'_>

Borrows the socket.
1.0.0 ·Source§

implDebug forTcpStream

Source§

fnfmt(&self, f: &mutFormatter<'_>) ->Result

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

implFrom<OwnedFd> forTcpStream

Available on(Unix or HermitCore ortarget_os=trusty or WASI ortarget_os=motor) and non-target_os=trusty only.
Source§

fnfrom(owned_fd:OwnedFd) -> Self

Converts to this type from the input type.
1.63.0 ·Source§

implFrom<OwnedSocket> forTcpStream

Available onWindows only.
Source§

fnfrom(owned:OwnedSocket) -> Self

Converts to this type from the input type.
1.63.0 ·Source§

implFrom<TcpStream> forOwnedFd

Available on(Unix or HermitCore ortarget_os=trusty or WASI ortarget_os=motor) and non-target_os=trusty only.
Source§

fnfrom(tcp_stream:TcpStream) ->OwnedFd

Takes ownership of aTcpStream’s socket file descriptor.

1.63.0 ·Source§

implFrom<TcpStream> forOwnedSocket

Available onWindows only.
Source§

fnfrom(tcp_stream:TcpStream) ->OwnedSocket

Takes ownership of aTcpStream’s socket.

1.1.0 ·Source§

implFromRawFd forTcpStream

Available onnon-target_os=trusty and (Unix or HermitCore ortarget_os=trusty or WASI ortarget_os=motor) only.
Source§

unsafe fnfrom_raw_fd(fd:RawFd) ->TcpStream

Constructs a new instance ofSelf from the given raw filedescriptor.Read more
1.1.0 ·Source§

implFromRawSocket forTcpStream

Available onWindows only.
Source§

unsafe fnfrom_raw_socket(sock:RawSocket) ->TcpStream

Constructs a new I/O object from the specified raw socket.Read more
1.4.0 ·Source§

implIntoRawFd forTcpStream

Available onnon-target_os=trusty and (Unix or HermitCore ortarget_os=trusty or WASI ortarget_os=motor) only.
Source§

fninto_raw_fd(self) ->RawFd

Consumes this object, returning the raw underlying file descriptor.Read more
1.4.0 ·Source§

implIntoRawSocket forTcpStream

Available onWindows only.
Source§

fninto_raw_socket(self) ->RawSocket

Consumes this object, returning the raw underlying socket.Read more
1.0.0 ·Source§

implRead for &TcpStream

Source§

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

Pull some bytes from this source into the specified buffer, returninghow many bytes were read.Read more
Source§

fnread_buf(&mut self, buf:BorrowedCursor<'_>) ->Result<()>

🔬This is a nightly-only experimental API. (read_buf #78485)
Pull some bytes from this source into the specified buffer.Read more
Source§

fnread_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) ->Result<usize>

Likeread, except that it reads into a slice of buffers.Read more
Source§

fnis_read_vectored(&self) ->bool

🔬This is a nightly-only experimental API. (can_vector #69941)
Determines if thisReader has an efficientread_vectoredimplementation.Read more
1.0.0 ·Source§

fnread_to_end(&mut self, buf: &mutVec<u8>) ->Result<usize>

Reads all bytes until EOF in this source, placing them intobuf.Read more
1.0.0 ·Source§

fnread_to_string(&mut self, buf: &mutString) ->Result<usize>

Reads all bytes until EOF in this source, appending them tobuf.Read more
1.6.0 ·Source§

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

Reads the exact number of bytes required to fillbuf.Read more
Source§

fnread_buf_exact(&mut self, cursor:BorrowedCursor<'_>) ->Result<()>

🔬This is a nightly-only experimental API. (read_buf #78485)
Reads the exact number of bytes required to fillcursor.Read more
1.0.0 ·Source§

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

Creates a “by reference” adapter for this instance ofRead.Read more
1.0.0 ·Source§

fnbytes(self) ->Bytes<Self>
where Self:Sized,

Transforms thisRead instance to anIterator over its bytes.Read more
1.0.0 ·Source§

fnchain<R:Read>(self, next: R) ->Chain<Self, R>
where Self:Sized,

Creates an adapter which will chain this stream with another.Read more
1.0.0 ·Source§

fntake(self, limit:u64) ->Take<Self>
where Self:Sized,

Creates an adapter which will read at mostlimit bytes from it.Read more
Source§

fnread_array<const N:usize>(&mut self) ->Result<[u8;N]>
where Self:Sized,

🔬This is a nightly-only experimental API. (read_array #148848)
Read and return a fixed array of bytes from this source.Read more
1.0.0 ·Source§

implRead forTcpStream

Source§

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

Pull some bytes from this source into the specified buffer, returninghow many bytes were read.Read more
Source§

fnread_buf(&mut self, buf:BorrowedCursor<'_>) ->Result<()>

🔬This is a nightly-only experimental API. (read_buf #78485)
Pull some bytes from this source into the specified buffer.Read more
Source§

fnread_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) ->Result<usize>

Likeread, except that it reads into a slice of buffers.Read more
Source§

fnis_read_vectored(&self) ->bool

🔬This is a nightly-only experimental API. (can_vector #69941)
Determines if thisReader has an efficientread_vectoredimplementation.Read more
1.0.0 ·Source§

fnread_to_end(&mut self, buf: &mutVec<u8>) ->Result<usize>

Reads all bytes until EOF in this source, placing them intobuf.Read more
1.0.0 ·Source§

fnread_to_string(&mut self, buf: &mutString) ->Result<usize>

Reads all bytes until EOF in this source, appending them tobuf.Read more
1.6.0 ·Source§

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

Reads the exact number of bytes required to fillbuf.Read more
Source§

fnread_buf_exact(&mut self, cursor:BorrowedCursor<'_>) ->Result<()>

🔬This is a nightly-only experimental API. (read_buf #78485)
Reads the exact number of bytes required to fillcursor.Read more
1.0.0 ·Source§

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

Creates a “by reference” adapter for this instance ofRead.Read more
1.0.0 ·Source§

fnbytes(self) ->Bytes<Self>
where Self:Sized,

Transforms thisRead instance to anIterator over its bytes.Read more
1.0.0 ·Source§

fnchain<R:Read>(self, next: R) ->Chain<Self, R>
where Self:Sized,

Creates an adapter which will chain this stream with another.Read more
1.0.0 ·Source§

fntake(self, limit:u64) ->Take<Self>
where Self:Sized,

Creates an adapter which will read at mostlimit bytes from it.Read more
Source§

fnread_array<const N:usize>(&mut self) ->Result<[u8;N]>
where Self:Sized,

🔬This is a nightly-only experimental API. (read_array #148848)
Read and return a fixed array of bytes from this source.Read more
1.89.0 ·Source§

implTcpStreamExt forTcpStream

Available onLinux or Android or Cygwin only.
Source§

fnset_quickack(&self, quickack:bool) ->Result<()>

Available onLinux only.
Enable or disableTCP_QUICKACK.Read more
Source§

fnquickack(&self) ->Result<bool>

Available onLinux only.
Gets the value of theTCP_QUICKACK option on this socket.Read more
Source§

fnset_deferaccept(&self, accept:Duration) ->Result<()>

🔬This is a nightly-only experimental API. (tcp_deferaccept #119639)
Available onLinux only.
A socket listener will be awakened solely when data arrives.Read more
Source§

fndeferaccept(&self) ->Result<Duration>

🔬This is a nightly-only experimental API. (tcp_deferaccept #119639)
Available onLinux only.
Gets the accept delay value of theTCP_DEFER_ACCEPT option.Read more
1.0.0 ·Source§

implWrite for &TcpStream

Source§

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

Writes a buffer into this writer, returning how many bytes were written.Read more
Source§

fnwrite_vectored(&mut self, bufs: &[IoSlice<'_>]) ->Result<usize>

Likewrite, except that it writes from a slice of buffers.Read more
Source§

fnis_write_vectored(&self) ->bool

🔬This is a nightly-only experimental API. (can_vector #69941)
Determines if thisWriter has an efficientwrite_vectoredimplementation.Read more
Source§

fnflush(&mut self) ->Result<()>

Flushes this output stream, ensuring that all intermediately bufferedcontents reach their destination.Read more
1.0.0 ·Source§

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

Attempts to write an entire buffer into this writer.Read more
Source§

fnwrite_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) ->Result<()>

🔬This is a nightly-only experimental API. (write_all_vectored #70436)
Attempts to write multiple buffers into this writer.Read more
1.0.0 ·Source§

fnwrite_fmt(&mut self, args:Arguments<'_>) ->Result<()>

Writes a formatted string into this writer, returning any errorencountered.Read more
1.0.0 ·Source§

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

Creates a “by reference” adapter for this instance ofWrite.Read more
1.0.0 ·Source§

implWrite forTcpStream

Source§

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

Writes a buffer into this writer, returning how many bytes were written.Read more
Source§

fnwrite_vectored(&mut self, bufs: &[IoSlice<'_>]) ->Result<usize>

Likewrite, except that it writes from a slice of buffers.Read more
Source§

fnis_write_vectored(&self) ->bool

🔬This is a nightly-only experimental API. (can_vector #69941)
Determines if thisWriter has an efficientwrite_vectoredimplementation.Read more
Source§

fnflush(&mut self) ->Result<()>

Flushes this output stream, ensuring that all intermediately bufferedcontents reach their destination.Read more
1.0.0 ·Source§

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

Attempts to write an entire buffer into this writer.Read more
Source§

fnwrite_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) ->Result<()>

🔬This is a nightly-only experimental API. (write_all_vectored #70436)
Attempts to write multiple buffers into this writer.Read more
1.0.0 ·Source§

fnwrite_fmt(&mut self, args:Arguments<'_>) ->Result<()>

Writes a formatted string into this writer, returning any errorencountered.Read more
1.0.0 ·Source§

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

Creates a “by reference” adapter for this instance ofWrite.Read more

Auto Trait Implementations§

§

implFreeze forTcpStream

§

implRefUnwindSafe forTcpStream

§

implSend forTcpStream

§

implSync forTcpStream

§

implUnpin forTcpStream

§

implUnwindSafe forTcpStream

Blanket Implementations§

Source§

impl<T>Any for T
where T: 'static + ?Sized,

Source§

fntype_id(&self) ->TypeId

Gets theTypeId ofself.Read more
Source§

impl<T>Borrow<T> for T
where T: ?Sized,

Source§

fnborrow(&self) ->&T

Immutably borrows from an owned value.Read more
Source§

impl<T>BorrowMut<T> for T
where T: ?Sized,

Source§

fnborrow_mut(&mut self) ->&mut T

Mutably borrows from an owned value.Read more
Source§

impl<T>From<T> for T

Source§

fnfrom(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U>Into<U> for T
where U:From<T>,

Source§

fninto(self) -> U

CallsU::from(self).

That is, this conversion is whatever the implementation ofFrom<T> for U chooses to do.

Source§

impl<T, U>TryFrom<U> for T
where U:Into<T>,

Source§

typeError =Infallible

The type returned in the event of a conversion error.
Source§

fntry_from(value: U) ->Result<T, <T asTryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U>TryInto<U> for T
where U:TryFrom<T>,

Source§

typeError = <U asTryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fntry_into(self) ->Result<U, <U asTryFrom<T>>::Error>

Performs the conversion.

[8]ページ先頭

©2009-2026 Movatter.jp