Struct breadx::connection::StdConnection
source · [−]#[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:
Read
Write
AsRawFd
for Unix platformsAsRawSocket
for Windows platforms
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
sourceimpl<C> StdConnection<C>
impl<C> StdConnection<C>
sourcepub fn new(inner: C) -> Self
pub fn new(inner: C) -> Self
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);
sourcepub fn into_inner(self) -> C
pub fn into_inner(self) -> C
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();
sourceimpl<C: ?Sized> StdConnection<C>
impl<C: ?Sized> StdConnection<C>
sourcepub fn get_ref(&self) -> &C
pub fn get_ref(&self) -> &C
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);
sourcepub fn get_mut(&mut self) -> &mut C
pub fn get_mut(&mut self) -> &mut C
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
sourceimpl<C: ?Sized> AsMut<C> for StdConnection<C>
impl<C: ?Sized> AsMut<C> for StdConnection<C>
sourceimpl<C: AsRawFd + ?Sized> AsRawFd for StdConnection<C>
impl<C: AsRawFd + ?Sized> AsRawFd for StdConnection<C>
sourceimpl<C: ?Sized> AsRef<C> for StdConnection<C>
impl<C: ?Sized> AsRef<C> for StdConnection<C>
sourceimpl<C> Borrow<C> for StdConnection<C>
impl<C> Borrow<C> for StdConnection<C>
sourceimpl<C> BorrowMut<C> for StdConnection<C>
impl<C> BorrowMut<C> for StdConnection<C>
sourcefn borrow_mut(&mut self) -> &mut C
fn borrow_mut(&mut self) -> &mut C
Mutably borrows from an owned value. Read more
sourceimpl<C: Clone + ?Sized> Clone for StdConnection<C>
impl<C: Clone + ?Sized> Clone for StdConnection<C>
sourcefn clone(&self) -> StdConnection<C>
fn clone(&self) -> StdConnection<C>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<C: Read + Write + AsRawFd + ?Sized> Connection for StdConnection<C>
impl<C: Read + Write + AsRawFd + ?Sized> Connection for StdConnection<C>
sourcefn send_slices_and_fds(
&mut self,
slices: &[IoSlice<'_>],
fds: &mut Vec<Fd>
) -> Result<usize>
fn send_slices_and_fds(
&mut self,
slices: &[IoSlice<'_>],
fds: &mut Vec<Fd>
) -> Result<usize>
Write a series of I/O slices and a series of file descriptors to the X11 server. Read more
sourcefn send_slices(&mut self, slices: &[IoSlice<'_>]) -> Result<usize>
fn send_slices(&mut self, slices: &[IoSlice<'_>]) -> Result<usize>
Write a series of I/O slices to the X11 server. Read more
sourcefn send_slice(&mut self, slice: &[u8]) -> Result<usize>
fn send_slice(&mut self, slice: &[u8]) -> Result<usize>
Write a slice of data to the X11 server. Read more
sourcefn recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
_fds: &mut Vec<Fd>
) -> Result<usize>
fn recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
_fds: &mut Vec<Fd>
) -> Result<usize>
Read data to a series of I/O slices and a buffer for file descriptors. Read more
sourcefn recv_slice_and_fds(
&mut self,
slice: &mut [u8],
_fds: &mut Vec<Fd>
) -> Result<usize>
fn recv_slice_and_fds(
&mut self,
slice: &mut [u8],
_fds: &mut Vec<Fd>
) -> Result<usize>
Read data to a single I/O slice and a buffer for file descriptors. Read more
sourcefn recv_slice(&mut self, slice: &mut [u8]) -> Result<usize>
fn recv_slice(&mut self, slice: &mut [u8]) -> Result<usize>
Read data for a single I/O slice. Read more
sourcefn non_blocking_recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
_fds: &mut Vec<Fd>
) -> Result<usize>
fn non_blocking_recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
_fds: &mut Vec<Fd>
) -> Result<usize>
Receive data from the X11 server into a set of I/O slices, in a non-blocking manner. Read more
sourceimpl<'a, C: AsRawFd + ?Sized> Connection for &'a StdConnection<C> where
&'a C: Read + Write,
impl<'a, C: AsRawFd + ?Sized> Connection for &'a StdConnection<C> where
&'a C: Read + Write,
sourcefn send_slices_and_fds(
&mut self,
slices: &[IoSlice<'_>],
fds: &mut Vec<Fd>
) -> Result<usize>
fn send_slices_and_fds(
&mut self,
slices: &[IoSlice<'_>],
fds: &mut Vec<Fd>
) -> Result<usize>
Write a series of I/O slices and a series of file descriptors to the X11 server. Read more
sourcefn send_slices(&mut self, slices: &[IoSlice<'_>]) -> Result<usize>
fn send_slices(&mut self, slices: &[IoSlice<'_>]) -> Result<usize>
Write a series of I/O slices to the X11 server. Read more
sourcefn send_slice(&mut self, slice: &[u8]) -> Result<usize>
fn send_slice(&mut self, slice: &[u8]) -> Result<usize>
Write a slice of data to the X11 server. Read more
sourcefn recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
_fds: &mut Vec<Fd>
) -> Result<usize>
fn recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
_fds: &mut Vec<Fd>
) -> Result<usize>
Read data to a series of I/O slices and a buffer for file descriptors. Read more
sourcefn recv_slice_and_fds(
&mut self,
slice: &mut [u8],
_fds: &mut Vec<Fd>
) -> Result<usize>
fn recv_slice_and_fds(
&mut self,
slice: &mut [u8],
_fds: &mut Vec<Fd>
) -> Result<usize>
Read data to a single I/O slice and a buffer for file descriptors. Read more
sourcefn recv_slice(&mut self, slice: &mut [u8]) -> Result<usize>
fn recv_slice(&mut self, slice: &mut [u8]) -> Result<usize>
Read data for a single I/O slice. Read more
sourcefn non_blocking_recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
_fds: &mut Vec<Fd>
) -> Result<usize>
fn non_blocking_recv_slices_and_fds(
&mut self,
slices: &mut [IoSliceMut<'_>],
_fds: &mut Vec<Fd>
) -> Result<usize>
Receive data from the X11 server into a set of I/O slices, in a non-blocking manner. Read more
sourceimpl<C: Debug> Debug for StdConnection<C>
impl<C: Debug> Debug for StdConnection<C>
sourceimpl<C: Default + ?Sized> Default for StdConnection<C>
impl<C: Default + ?Sized> Default for StdConnection<C>
sourcefn default() -> StdConnection<C>
fn default() -> StdConnection<C>
Returns the “default value” for a type. Read more
sourceimpl<C> Deref for StdConnection<C>
impl<C> Deref for StdConnection<C>
sourceimpl<C> DerefMut for StdConnection<C>
impl<C> DerefMut for StdConnection<C>
sourceimpl<C> From<C> for StdConnection<C>
impl<C> From<C> for StdConnection<C>
sourceimpl<C: Hash + ?Sized> Hash for StdConnection<C>
impl<C: Hash + ?Sized> Hash for StdConnection<C>
sourceimpl<C: Ord + ?Sized> Ord for StdConnection<C>
impl<C: Ord + ?Sized> Ord for StdConnection<C>
sourceimpl<C: PartialEq + ?Sized> PartialEq<StdConnection<C>> for StdConnection<C>
impl<C: PartialEq + ?Sized> PartialEq<StdConnection<C>> for StdConnection<C>
sourcefn eq(&self, other: &StdConnection<C>) -> bool
fn eq(&self, other: &StdConnection<C>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &StdConnection<C>) -> bool
fn ne(&self, other: &StdConnection<C>) -> bool
This method tests for !=
.
sourceimpl<C: PartialOrd + ?Sized> PartialOrd<StdConnection<C>> for StdConnection<C>
impl<C: PartialOrd + ?Sized> PartialOrd<StdConnection<C>> for StdConnection<C>
sourcefn partial_cmp(&self, other: &StdConnection<C>) -> Option<Ordering>
fn partial_cmp(&self, other: &StdConnection<C>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<C: Copy + ?Sized> Copy for StdConnection<C>
impl<C: Eq + ?Sized> Eq for StdConnection<C>
impl<C: ?Sized> StructuralEq for StdConnection<C>
impl<C: ?Sized> StructuralPartialEq for StdConnection<C>
Auto Trait Implementations
impl<C: ?Sized> RefUnwindSafe for StdConnection<C> where
C: RefUnwindSafe,
impl<C: ?Sized> Send for StdConnection<C> where
C: Send,
impl<C: ?Sized> Sync for StdConnection<C> where
C: Sync,
impl<C: ?Sized> Unpin for StdConnection<C> where
C: Unpin,
impl<C: ?Sized> UnwindSafe for StdConnection<C> where
C: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CallHasher for T where
T: Hash + ?Sized,
impl<T> CallHasher for T where
T: Hash + ?Sized,
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more