# socket2::SockRef - Rust
API documentation for the Rust `SockRef` struct in crate `socket2`.
Keywords: rust, rustlang, rust-lang, SockRef

# Struct socket2::SockRef [−] [src]

    pub struct SockRef<'s> { /* fields omitted */ }

A reference to a `Socket` that can be used to configure socket types other than the `Socket` type itself.

This allows for example a `TcpStream`, found in the standard library, to be configured using all the additional methods found in the `Socket` API.

`SockRef` can be created from any socket type that implements `AsRawFd` (Unix) or `AsRawSocket` (Windows) using the `From` implementation, but the caller must ensure the file descriptor/socket is a valid.

# Examples

    use std::net::{TcpStream, SocketAddr};

    use socket2::SockRef;

    // Create `TcpStream` from the standard library.
    let address: SocketAddr = "127.0.0.1:1234".parse()?;
    let stream = TcpStream::connect(address)?;

    // Create a `SockRef`erence to the stream.
    let socket_ref = SockRef::from(&stream);
    // Use `Socket::set_nodelay` on the stream.
    socket_ref.set_nodelay(true)?;
    drop(socket_ref);

    assert_eq!(stream.nodelay()?, true);

## Methods from Deref<Target = Socket>

#### `pub fn bind(&self, address: &SockAddr) -> Result<()>` [src]

Binds this socket to the specified address.

This function directly corresponds to the `bind(2)` function on Windows and Unix.

#### `pub fn connect(&self, address: &SockAddr) -> Result<()>` [src]

Initiate a connection on this socket to the specified address.

This function directly corresponds to the `connect(2)` function on Windows and Unix.

An error will be returned if `listen` or `connect` has already been called on this builder.

# Notes

When using a non-blocking connect (by setting the socket into non-blocking mode before calling this function), socket option can't be set while connecting. This will cause errors on Windows. Socket options can be safely set before and after connecting the socket.

#### `pub fn connect_timeout(&self, addr: &SockAddr, timeout: Duration) -> Result<()>` [src]

Initiate a connection on this socket to the specified address, only only waiting for a certain period of time for the connection to be established.

Unlike many other methods on `Socket`, this does not correspond to a single C function. It sets the socket to nonblocking mode, connects via connect(2), and then waits for the connection to complete with poll(2) on Unix and select on Windows. When the connection is complete, the socket is set back to blocking mode. On Unix, this will loop over `EINTR` errors.

# Warnings

The non-blocking state of the socket is overridden by this function - it will be returned in blocking mode on success, and in an indeterminate state on failure.

If the connection request times out, it may still be processing in the background - a second call to `connect` or `connect_timeout` may fail.

#### `pub fn listen(&self, backlog: c_int) -> Result<()>` [src]

Mark a socket as ready to accept incoming connection requests using `Socket::accept()`.

This function directly corresponds to the `listen(2)` function on Windows and Unix.

An error will be returned if `listen` or `connect` has already been called on this builder.

#### `pub fn accept(&self) -> Result<(Socket, SockAddr)>` [src]

Accept a new incoming connection from this listener.

This function uses `accept4(2)` on platforms that support it and `accept(2)` platforms that do not.

This function sets the same flags as in done for `Socket::new`, `Socket::accept_raw` can be used if you don't want to set those flags.

#### `pub fn accept_raw(&self) -> Result<(Socket, SockAddr)>` [src]

Accept a new incoming connection from this listener.

This function directly corresponds to the `accept(2)` function on Windows and Unix.

#### `pub fn local_addr(&self) -> Result<SockAddr>` [src]

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

# Notes

Depending on the OS this may return an error if the socket is not bound.

#### `pub fn peer_addr(&self) -> Result<SockAddr>` [src]

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

# Notes

This returns an error if the socket is not `connect`ed.

#### `pub fn try_clone(&self) -> Result<Socket>` [src]

Creates a new independently owned handle to the underlying socket.

# Notes

On Unix this uses `F_DUPFD_CLOEXEC` and thus sets the `FD_CLOEXEC` on the returned socket.

On Windows this uses `WSA_FLAG_NO_HANDLE_INHERIT` setting inheriting to false.

On Windows this can not be used function cannot be used on a QOS-enabled socket, see https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaduplicatesocketw.

#### `pub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>` [src]

Moves this TCP stream into or out of nonblocking mode.

# Notes

On Unix this corresponds to calling `fcntl` (un)setting `O_NONBLOCK`.

On Windows this corresponds to calling `ioctlsocket` (un)setting `FIONBIO`.

#### `pub fn shutdown(&self, how: Shutdown) -> Result<()>` [src]

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

This function will cause all pending and future I/O on the specified portions to return immediately with an appropriate value.

#### `pub fn recv(&self, buf: &mut [MaybeUninit<u8>]) -> Result<usize>` [src]

Receives data on the socket from the remote address to which it is connected.

The `connect` method will connect this socket to a remote address. This method might fail if the socket is not connected.

# Safety

Normally casting a `&mut [u8]` to `&mut [MaybeUninit<u8>]` would be unsound, as that allows us to write uninitialised bytes to the buffer. However this implementation promises to not write uninitialised bytes to the `buf`fer and passes it directly to `recv(2)` system call. This promise ensures that this function can be called using a `buf`fer of type `&mut [u8]`.

Note that the `io::Read::read` implementation calls this function with a `buf`fer of type `&mut [u8]`, allowing initialised buffers to be used without using `unsafe`.

#### `pub fn recv_out_of_band(&self, buf: &mut [MaybeUninit<u8>]) -> Result<usize>` [src]

Receives out-of-band (OOB) data on the socket from the remote address to which it is connected by setting the `MSG_OOB` flag for this call.

For more information, see `recv`, `out_of_band_inline`.

#### `pub fn recv_with_flags(
&self,
buf: &mut [MaybeUninit<u8>],
flags: c_int
) -> Result<usize>` [src]

Identical to `recv` but allows for specification of arbitrary flags to the underlying `recv` call.

#### `pub fn recv_vectored(
&self,
bufs: &mut [MaybeUninitSlice<'_>]
) -> Result<(usize, RecvFlags)>` [src]

Receives data on the socket from the remote address to which it is connected. Unlike `recv` this allows passing multiple buffers.

The `connect` method will connect this socket to a remote address. This method might fail if the socket is not connected.

In addition to the number of bytes read, this function returns the flags for the received message. See `RecvFlags` for more information about the returned flags.

# Safety

Normally casting a `IoSliceMut` to `MaybeUninitSlice` would be unsound, as that allows us to write uninitialised bytes to the buffer. However this implementation promises to not write uninitialised bytes to the `bufs` and passes it directly to `recvmsg(2)` system call. This promise ensures that this function can be called using `bufs` of type `&mut [IoSliceMut]`.

Note that the `io::Read::read_vectored` implementation calls this function with `buf`s of type `&mut [IoSliceMut]`, allowing initialised buffers to be used without using `unsafe`.

#### `pub fn recv_vectored_with_flags(
&self,
bufs: &mut [MaybeUninitSlice<'_>],
flags: c_int
) -> Result<(usize, RecvFlags)>` [src]

Identical to `recv_vectored` but allows for specification of arbitrary flags to the underlying `recvmsg`/`WSARecv` call.

# Safety

`recv_from_vectored` makes the same safety guarantees regarding `bufs` as `recv_vectored`.

#### `pub fn peek(&self, buf: &mut [MaybeUninit<u8>]) -> Result<usize>` [src]

Receives data on the socket from the remote adress to which it is connected, 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 passing `MSG_PEEK` as a flag to the underlying `recv` system call.

# Safety

`peek` makes the same safety guarantees regarding the `buf`fer as `recv`.

#### `pub fn recv_from(
&self,
buf: &mut [MaybeUninit<u8>]
) -> Result<(usize, SockAddr)>` [src]

Receives data from the socket. On success, returns the number of bytes read and the address from whence the data came.

# Safety

`recv_from` makes the same safety guarantees regarding the `buf`fer as `recv`.

#### `pub fn recv_from_with_flags(
&self,
buf: &mut [MaybeUninit<u8>],
flags: c_int
) -> Result<(usize, SockAddr)>` [src]

Identical to `recv_from` but allows for specification of arbitrary flags to the underlying `recvfrom` call.

#### `pub fn recv_from_vectored(
&self,
bufs: &mut [MaybeUninitSlice<'_>]
) -> Result<(usize, RecvFlags, SockAddr)>` [src]

Receives data from the socket. Returns the amount of bytes read, the `RecvFlags` and the remote address from the data is coming. Unlike `recv_from` this allows passing multiple buffers.

# Safety

`recv_from_vectored` makes the same safety guarantees regarding `bufs` as `recv_vectored`.

#### `pub fn recv_from_vectored_with_flags(
&self,
bufs: &mut [MaybeUninitSlice<'_>],
flags: c_int
) -> Result<(usize, RecvFlags, SockAddr)>` [src]

Identical to `recv_from_vectored` but allows for specification of arbitrary flags to the underlying `recvmsg`/`WSARecvFrom` call.

# Safety

`recv_from_vectored` makes the same safety guarantees regarding `bufs` as `recv_vectored`.

#### `pub fn peek_from(
&self,
buf: &mut [MaybeUninit<u8>]
) -> Result<(usize, SockAddr)>` [src]

Receives data from the socket, without removing it from the queue.

Successive calls return the same data. This is accomplished by passing `MSG_PEEK` as a flag to the underlying `recvfrom` system call.

On success, returns the number of bytes peeked and the address from whence the data came.

# Safety

`peek_from` makes the same safety guarantees regarding the `buf`fer as `recv`.

#### `pub fn send(&self, buf: &[u8]) -> Result<usize>` [src]

Sends data on the socket to a connected peer.

This is typically used on TCP sockets or datagram sockets which have been connected.

On success returns the number of bytes that were sent.

#### `pub fn send_with_flags(&self, buf: &[u8], flags: c_int) -> Result<usize>` [src]

Identical to `send` but allows for specification of arbitrary flags to the underlying `send` call.

#### `pub fn send_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<usize>` [src]

Send data to the connected peer. Returns the amount of bytes written.

#### `pub fn send_vectored_with_flags(
&self,
bufs: &[IoSlice<'_>],
flags: c_int
) -> Result<usize>` [src]

Identical to `send_vectored` but allows for specification of arbitrary flags to the underlying `sendmsg`/`WSASend` call.

#### `pub fn send_out_of_band(&self, buf: &[u8]) -> Result<usize>` [src]

Sends out-of-band (OOB) data on the socket to connected peer by setting the `MSG_OOB` flag for this call.

For more information, see `send`, `out_of_band_inline`.

#### `pub fn send_to(&self, buf: &[u8], addr: &SockAddr) -> Result<usize>` [src]

Sends data on the socket to the given address. On success, returns the number of bytes written.

This is typically used on UDP or datagram-oriented sockets.

#### `pub fn send_to_with_flags(
&self,
buf: &[u8],
addr: &SockAddr,
flags: c_int
) -> Result<usize>` [src]

Identical to `send_to` but allows for specification of arbitrary flags to the underlying `sendto` call.

#### `pub fn send_to_vectored(
&self,
bufs: &[IoSlice<'_>],
addr: &SockAddr
) -> Result<usize>` [src]

Send data to a peer listening on `addr`. Returns the amount of bytes written.

#### `pub fn send_to_vectored_with_flags(
&self,
bufs: &[IoSlice<'_>],
addr: &SockAddr,
flags: c_int
) -> Result<usize>` [src]

Identical to `send_to_vectored` but allows for specification of arbitrary flags to the underlying `sendmsg`/`WSASendTo` call.

#### `pub fn broadcast(&self) -> Result<bool>` [src]

Get the value of the `SO_BROADCAST` option for this socket.

For more information about this option, see `set_broadcast`.

#### `pub fn set_broadcast(&self, broadcast: bool) -> Result<()>` [src]

Set the value of the `SO_BROADCAST` option for this socket.

When enabled, this socket is allowed to send packets to a broadcast address.

#### `pub fn take_error(&self) -> Result<Option<Error>>` [src]

Get the value of the `SO_ERROR` option on this socket.

This will retrieve the stored error in the underlying socket, clearing the field in the process. This can be useful for checking errors between calls.

#### `pub fn keepalive(&self) -> Result<bool>` [src]

Get the value of the `SO_KEEPALIVE` option on this socket.

For more information about this option, see `set_keepalive`.

#### `pub fn set_keepalive(&self, keepalive: bool) -> Result<()>` [src]

Set value for the `SO_KEEPALIVE` option on this socket.

Enable sending of keep-alive messages on connection-oriented sockets.

#### `pub fn linger(&self) -> Result<Option<Duration>>` [src]

Get the value of the `SO_LINGER` option on this socket.

For more information about this option, see `set_linger`.

#### `pub fn set_linger(&self, linger: Option<Duration>) -> Result<()>` [src]

Set value for the `SO_LINGER` option on this socket.

If `linger` is not `None`, a close(2) or shutdown(2) will not return until all queued messages for the socket have been successfully sent or the linger timeout has been reached. Otherwise, the call returns immediately and the closing is done in the background. When the socket is closed as part of exit(2), it always lingers in the background.

# Notes

On most OSs the duration only has a precision of seconds and will be silently truncated.

On Apple platforms (e.g. macOS, iOS, etc) this uses `SO_LINGER_SEC`.

#### `pub fn out_of_band_inline(&self) -> Result<bool>` [src]

Get value for the `SO_OOBINLINE` option on this socket.

For more information about this option, see `set_out_of_band_inline`.

#### `pub fn set_out_of_band_inline(&self, oob_inline: bool) -> Result<()>` [src]

Set value for the `SO_OOBINLINE` option on this socket.

If this option is enabled, out-of-band data is directly placed into the receive data stream. Otherwise, out-of-band data is passed only when the `MSG_OOB` flag is set during receiving. As per RFC6093, TCP sockets using the Urgent mechanism are encouraged to set this flag.

#### `pub fn recv_buffer_size(&self) -> Result<usize>` [src]

Get value for the `SO_RCVBUF` option on this socket.

For more information about this option, see `set_recv_buffer_size`.

#### `pub fn set_recv_buffer_size(&self, size: usize) -> Result<()>` [src]

Set value for the `SO_RCVBUF` option on this socket.

Changes the size of the operating system's receive buffer associated with the socket.

#### `pub fn read_timeout(&self) -> Result<Option<Duration>>` [src]

Get value for the `SO_RCVTIMEO` option on this socket.

If the returned timeout is `None`, then `read` and `recv` calls will block indefinitely.

#### `pub fn set_read_timeout(&self, duration: Option<Duration>) -> Result<()>` [src]

Set value for the `SO_RCVTIMEO` option on this socket.

If `timeout` is `None`, then `read` and `recv` calls will block indefinitely.

#### `pub fn reuse_address(&self) -> Result<bool>` [src]

Get the value of the `SO_REUSEADDR` option on this socket.

For more information about this option, see `set_reuse_address`.

#### `pub fn set_reuse_address(&self, reuse: bool) -> Result<()>` [src]

Set value for the `SO_REUSEADDR` option on this socket.

This indicates that futher calls to `bind` may allow reuse of local addresses. For IPv4 sockets this means that a socket may bind even when there's a socket already listening on this port.

#### `pub fn send_buffer_size(&self) -> Result<usize>` [src]

Get the value of the `SO_SNDBUF` option on this socket.

For more information about this option, see `set_send_buffer_size`.

#### `pub fn set_send_buffer_size(&self, size: usize) -> Result<()>` [src]

Set value for the `SO_SNDBUF` option on this socket.

Changes the size of the operating system's send buffer associated with the socket.

#### `pub fn write_timeout(&self) -> Result<Option<Duration>>` [src]

Get value for the `SO_SNDTIMEO` option on this socket.

If the returned timeout is `None`, then `write` and `send` calls will block indefinitely.

#### `pub fn set_write_timeout(&self, duration: Option<Duration>) -> Result<()>` [src]

Set value for the `SO_SNDTIMEO` option on this socket.

If `timeout` is `None`, then `write` and `send` calls will block indefinitely.

#### `pub fn join_multicast_v4(
&self,
multiaddr: &Ipv4Addr,
interface: &Ipv4Addr
) -> Result<()>` [src]

Join a multicast group using `IP_ADD_MEMBERSHIP` option on this socket.

This function specifies a new multicast group for this socket to join. The address must be a valid multicast address, and `interface` is the address of the local interface with which the system should join the multicast group. If it's `Ipv4Addr::UNSPECIFIED` (`INADDR_ANY`) then an appropriate interface is chosen by the system.

#### `pub fn leave_multicast_v4(
&self,
multiaddr: &Ipv4Addr,
interface: &Ipv4Addr
) -> Result<()>` [src]

Leave a multicast group using `IP_DROP_MEMBERSHIP` option on this socket.

For more information about this option, see `join_multicast_v4`.

#### `pub fn multicast_if_v4(&self) -> Result<Ipv4Addr>` [src]

Get the value of the `IP_MULTICAST_IF` option for this socket.

For more information about this option, see `set_multicast_if_v4`.

#### `pub fn set_multicast_if_v4(&self, interface: &Ipv4Addr) -> Result<()>` [src]

Set the value of the `IP_MULTICAST_IF` option for this socket.

Specifies the interface to use for routing multicast packets.

#### `pub fn multicast_loop_v4(&self) -> Result<bool>` [src]

Get the value of the `IP_MULTICAST_LOOP` option for this socket.

For more information about this option, see `set_multicast_loop_v4`.

#### `pub fn set_multicast_loop_v4(&self, loop_v4: bool) -> Result<()>` [src]

Set the value of the `IP_MULTICAST_LOOP` option for this socket.

If enabled, multicast packets will be looped back to the local socket. Note that this may not have any affect on IPv6 sockets.

#### `pub fn multicast_ttl_v4(&self) -> Result<u32>` [src]

Get the value of the `IP_MULTICAST_TTL` option for this socket.

For more information about this option, see `set_multicast_ttl_v4`.

#### `pub fn set_multicast_ttl_v4(&self, ttl: u32) -> Result<()>` [src]

Set the value of the `IP_MULTICAST_TTL` option for this socket.

Indicates the time-to-live value of outgoing multicast packets for this socket. The default value is 1 which means that multicast packets don't leave the local network unless explicitly requested.

Note that this may not have any affect on IPv6 sockets.

#### `pub fn ttl(&self) -> Result<u32>` [src]

Get the value of the `IP_TTL` option for this socket.

For more information about this option, see `set_ttl`.

#### `pub fn set_ttl(&self, ttl: u32) -> Result<()>` [src]

Set the value of the `IP_TTL` option for this socket.

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

#### `pub fn join_multicast_v6(
&self,
multiaddr: &Ipv6Addr,
interface: u32
) -> Result<()>` [src]

Join a multicast group using `IPV6_ADD_MEMBERSHIP` option on this socket.

Some OSs use `IPV6_JOIN_GROUP` for this option.

This function specifies a new multicast group for this socket to join. The address must be a valid multicast address, and `interface` is the index of the interface to join/leave (or 0 to indicate any interface).

#### `pub fn leave_multicast_v6(
&self,
multiaddr: &Ipv6Addr,
interface: u32
) -> Result<()>` [src]

Leave a multicast group using `IPV6_DROP_MEMBERSHIP` option on this socket.

Some OSs use `IPV6_LEAVE_GROUP` for this option.

For more information about this option, see `join_multicast_v6`.

#### `pub fn multicast_hops_v6(&self) -> Result<u32>` [src]

Get the value of the `IPV6_MULTICAST_HOPS` option for this socket

For more information about this option, see `set_multicast_hops_v6`.

#### `pub fn set_multicast_hops_v6(&self, hops: u32) -> Result<()>` [src]

Set the value of the `IPV6_MULTICAST_HOPS` option for this socket

Indicates the number of "routers" multicast packets will transit for this socket. The default value is 1 which means that multicast packets don't leave the local network unless explicitly requested.

#### `pub fn multicast_if_v6(&self) -> Result<u32>` [src]

Get the value of the `IPV6_MULTICAST_IF` option for this socket.

For more information about this option, see `set_multicast_if_v6`.

#### `pub fn set_multicast_if_v6(&self, interface: u32) -> Result<()>` [src]

Set the value of the `IPV6_MULTICAST_IF` option for this socket.

Specifies the interface to use for routing multicast packets. Unlike ipv4, this is generally required in ipv6 contexts where network routing prefixes may overlap.

#### `pub fn multicast_loop_v6(&self) -> Result<bool>` [src]

Get the value of the `IPV6_MULTICAST_LOOP` option for this socket.

For more information about this option, see `set_multicast_loop_v6`.

#### `pub fn set_multicast_loop_v6(&self, loop_v6: bool) -> Result<()>` [src]

Set the value of the `IPV6_MULTICAST_LOOP` option for this socket.

Controls whether this socket sees the multicast packets it sends itself. Note that this may not have any affect on IPv4 sockets.

#### `pub fn unicast_hops_v6(&self) -> Result<u32>` [src]

Get the value of the `IPV6_UNICAST_HOPS` option for this socket.

Specifies the hop limit for ipv6 unicast packets

#### `pub fn set_unicast_hops_v6(&self, hops: u32) -> Result<()>` [src]

Set the value for the `IPV6_UNICAST_HOPS` option on this socket.

Specifies the hop limit for ipv6 unicast packets

#### `pub fn only_v6(&self) -> Result<bool>` [src]

Get the value of the `IPV6_V6ONLY` option for this socket.

For more information about this option, see `set_only_v6`.

#### `pub fn set_only_v6(&self, only_v6: bool) -> Result<()>` [src]

Set the value for the `IPV6_V6ONLY` option on this socket.

If this is set to `true` then the socket is restricted to sending and receiving IPv6 packets only. In this case two IPv4 and IPv6 applications can bind the same port at the same time.

If this is set to `false` then the socket can be used to send and receive packets from an IPv4-mapped IPv6 address.

#### `pub fn set_tcp_keepalive(&self, params: &TcpKeepalive) -> Result<()>` [src]

Set parameters configuring TCP keepalive probes for this socket.

The supported parameters depend on the operating system, and are configured using the `TcpKeepalive` struct. At a minimum, all systems support configuring the keepalive time: the time after which the OS will start sending keepalive messages on an idle connection.

# Notes

- This will enable `SO_KEEPALIVE` on this socket, if it is not already enabled.
- On some platforms, such as Windows, any keepalive parameters not configured by the `TcpKeepalive` struct passed to this function may be overwritten with their default values. Therefore, this function should either only be called once per socket, or the same parameters should be passed every time it is called.

# Examples

    use std::time::Duration;

    use socket2::{Socket, TcpKeepalive, Domain, Type};

    let socket = Socket::new(Domain::IPV4, Type::STREAM, None)?;
    let keepalive = TcpKeepalive::new()
        .with_time(Duration::from_secs(4));
        // Depending on the target operating system, we may also be able to
        // configure the keepalive probe interval and/or the number of
        // retries here as well.

    socket.set_tcp_keepalive(&keepalive)?;

#### `pub fn nodelay(&self) -> Result<bool>` [src]

Get the value of the `TCP_NODELAY` option on this socket.

For more information about this option, see `set_nodelay`.

#### `pub fn set_nodelay(&self, nodelay: bool) -> Result<()>` [src]

Set the value of the `TCP_NODELAY` option on this socket.

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

## Trait Implementations

### `impl Debug for SockRef<'_>` [src]

#### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` [src]

Formats the value using the given formatter. Read more

### `impl<'s> Deref for SockRef<'s>` [src]

#### `type Target = Socket`

The resulting type after dereferencing.

#### `fn deref(&self) -> &Self::Target` [src]

Dereferences the value.

### `impl<'s, S> From<&'s S> for SockRef<'s> where
S: AsRawFd,` [src]

#### `fn from(socket: &'s S) -> Self` [src]

The caller must ensure `S` is actually a socket.

## Auto Trait Implementations

### `impl<'s> RefUnwindSafe for SockRef<'s>` [src]

### `impl<'s> Send for SockRef<'s>` [src]

### `impl<'s> Sync for SockRef<'s>` [src]

### `impl<'s> Unpin for SockRef<'s>` [src]

### `impl<'s> UnwindSafe for SockRef<'s>` [src]

## Blanket Implementations

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `pub fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

### `impl<T> From<T> for T` [src]

#### `pub fn from(t: T) -> T` [src]

Performs the conversion.

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `pub fn into(self) -> U` [src]

Performs the conversion.

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `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]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

#### `pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.