#[repr(transparent)]
pub struct StdConnection<C: ?Sized> { /* private fields */ }
Expand description

A newtype wrapper around a type that implements Connection for certain types in the standard library.

Types within the Rust ecosystem can function as a reliable byte steam. This newtype allows these tpyes to be used in places that expect a Connection. Connection is implemented for types that implement the following traits:

In addition, if Read and Write are implemented for &T, then Connection is implemented for &StdConnection<T>, allowing it to be used in shared contexts.

This type does not preform FD passing. If you need to pass file descriptors, either use NameConnection, SendmsgConnection, or build your own type.

Example

use breadx::connection::{Connection, StdConnection};
use std::net::TcpStream;

let socket = TcpStream::connect("localhost:6000")?;
let mut connection = StdConnection::new(socket);
let mut buf = [0; 1024];
connection.recv_slice(&mut buf)?;

Implementations

Create a new StdConnection wrapping around an existing connection.

Example
use breadx::connection::{Connection, StdConnection};
use std::net::TcpStream;

let socket = TcpStream::connect("localhost:6000")?;
let connection = StdConnection::new(socket);

Unwrap this newtype to get the underlying connection.

Example
use breadx::connection::{Connection, StdConnection};
use std::net::TcpStream;

let socket = TcpStream::connect("localhost:6000")?;
let connection = StdConnection::new(socket);

// we need the connection back
let socket = connection.into_inner();

Get a reference to the underlying connection.

Example
use breadx::connection::{Connection, StdConnection};
use std::net::TcpStream;

let socket = TcpStream::connect("localhost:6000")?;
let connection = StdConnection::new(socket);

let peer_addr = connection.get_ref().peer_addr()?;
println!("peer address: {}", peer_addr);

Get a mutable reference to the underlying connection.

Example
use breadx::connection::{Connection, StdConnection};
use std::net::TcpStream;

let socket = TcpStream::connect("localhost:6000")?;
let mut connection = StdConnection::new(socket);

let peer_addr = connection.get_mut().peer_addr()?;
println!("peer address: {}", peer_addr);

Trait Implementations

Converts this type into a mutable reference of the (usually inferred) input type.

Extracts the raw file descriptor. Read more

Converts this type into a shared reference of the (usually inferred) input type.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Write a series of I/O slices and a series of file descriptors to the X11 server. Read more

Write a series of I/O slices to the X11 server. Read more

Write a slice of data to the X11 server. Read more

Read data to a series of I/O slices and a buffer for file descriptors. Read more

Read data to a single I/O slice and a buffer for file descriptors. Read more

Read data for a single I/O slice. Read more

Flush all data in this connection’s buffer. Read more

Receive data from the X11 server into a set of I/O slices, in a non-blocking manner. Read more

Receive data from the X11 server into a single slice, in a non-blocking manner. Read more

Shutdown this connection. Read more

Write a series of I/O slices and a series of file descriptors to the X11 server. Read more

Write a series of I/O slices to the X11 server. Read more

Write a slice of data to the X11 server. Read more

Read data to a series of I/O slices and a buffer for file descriptors. Read more

Read data to a single I/O slice and a buffer for file descriptors. Read more

Read data for a single I/O slice. Read more

Flush all data in this connection’s buffer. Read more

Receive data from the X11 server into a set of I/O slices, in a non-blocking manner. Read more

Receive data from the X11 server into a single slice, in a non-blocking manner. Read more

Shutdown this connection. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts to this type from the input type.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more