Struct netservices::resource::NetTransport
source · pub struct NetTransport<S: NetSession> { /* private fields */ }
Expand description
Net transport is an adaptor around specific NetSession
(implementing
session management, including optional handshake, encoding etc) to be used
as a transport resource in a reactor::Reactor
.
Implementations§
source§impl<S: NetSession> NetTransport<S>
impl<S: NetSession> NetTransport<S>
pub fn accept(session: S) -> Result<Self>
sourcepub fn with_session(session: S, link_direction: LinkDirection) -> Result<Self>
pub fn with_session(session: S, link_direction: LinkDirection) -> Result<Self>
Constructs reactor-managed resource around an existing NetSession
.
NB: Must not be called for connections created in a non-blocking mode!
Errors
If a session can be put into a non-blocking mode.
sourcepub fn into_session(self) -> Result<S, (Self, Error)>
pub fn into_session(self) -> Result<S, (Self, Error)>
Tries to unwrap the underlying NetSession
object.
Attempts to empty data buffered for a write operation in a non-blocking
way. If the non-blocking emptying is not possible errors with
io::ErrorKind::WouldBlock
kind of io::Error
.
Errors
Returns the consumed self
as a part of an error.
If the write buffer can’t be emptied in a non-blocking way errors with
io::ErrorKind::WouldBlock
kind of io::Error
.
If the connection is failed and the write buffer has some data, errors with the connection failure code.
pub fn state(&self) -> TransportState
pub fn is_active(&self) -> bool
pub fn is_inbound(&self) -> bool
pub fn is_outbound(&self) -> bool
pub fn link_direction(&self) -> LinkDirection
pub fn local_addr(&self) -> <S::Connection as NetConnection>::Addr
pub fn artifact(&self) -> Option<S::Artifact>
pub fn expect_peer_id(&self) -> S::Artifact
pub fn write_buf_len(&self) -> usize
Trait Implementations§
source§impl<S: NetSession> AsRawFd for NetTransport<S>
impl<S: NetSession> AsRawFd for NetTransport<S>
source§impl<S: Debug + NetSession> Debug for NetTransport<S>
impl<S: Debug + NetSession> Debug for NetTransport<S>
source§impl<S: NetSession> Display for NetTransport<S>
impl<S: NetSession> Display for NetTransport<S>
source§impl<S: NetSession> Resource for NetTransport<S>
impl<S: NetSession> Resource for NetTransport<S>
§type Event = SessionEvent<S>
type Event = SessionEvent<S>
Self::handle_io
. These events are passed to the reactor crate::Handler
.source§fn id(&self) -> Self::Id
fn id(&self) -> Self::Id
ResourceId
.source§impl<S: NetSession> Write for NetTransport<S>
impl<S: NetSession> Write for NetTransport<S>
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)source§impl<S: NetSession> WriteAtomic for NetTransport<S>
impl<S: NetSession> WriteAtomic for NetTransport<S>
source§fn is_ready_to_write(&self) -> bool
fn is_ready_to_write(&self) -> bool
source§fn empty_write_buf(&mut self) -> Result<bool>
fn empty_write_buf(&mut self) -> Result<bool>
io::ErrorKind::WouldBlock
kind of io::Error
. Read moresource§fn write_or_buf(&mut self, buf: &[u8]) -> Result<()>
fn write_or_buf(&mut self, buf: &[u8]) -> Result<()>
source§fn write_atomic(&mut self, buf: &[u8]) -> Result<(), WriteError>
fn write_atomic(&mut self, buf: &[u8]) -> Result<(), WriteError>
WriteError::NotReady
error.