[][src]Trait romio::raw::TakeError

pub trait TakeError {
    type Ok: Error + Send + Sync;
    type Err: Error + Send + Sync;
    fn take_error(&self) -> Result<Option<Self::Ok>, Self::Err>;
}

Extract an error from the underlying struct that isn't propagated through regular channels.

This is common in TcpListener / UdsStream structs where this trait can be used to access the SO_ERROR option on the socket.

Both Ok and Err are error types. If no error exists take_error should return Ok(None).

Associated Types

type Ok: Error + Send + Sync

The type of successful values yielded by this trait.

type Err: Error + Send + Sync

The type of failures yielded by this trait.

Loading content...

Required methods

fn take_error(&self) -> Result<Option<Self::Ok>, Self::Err>

Return an underlying error value of the struct.

Loading content...

Implementors

impl TakeError for UnixDatagram[src]

type Ok = Error

type Err = Error

fn take_error(&self) -> Result<Option<Self::Ok>, Self::Err>[src]

Returns the value of the SO_ERROR option.

Examples

use romio::raw::TakeError;
use romio::uds::UnixDatagram;

let stream = UnixDatagram::bind("/tmp/sock")?;
if let Ok(Some(err)) = stream.take_error() {
    println!("Got error: {:?}", err);
}

impl TakeError for UnixListener[src]

type Ok = Error

type Err = Error

fn take_error(&self) -> Result<Option<Self::Ok>, Self::Err>[src]

Returns the value of the SO_ERROR option.

Examples

use romio::uds::UnixListener;
use romio::raw::TakeError;

let listener = UnixListener::bind("/tmp/sock")?;
if let Ok(Some(err)) = listener.take_error() {
    println!("Got error: {:?}", err);
}

impl TakeError for UnixStream[src]

type Ok = Error

type Err = Error

fn take_error(&self) -> Result<Option<Self::Ok>, Self::Err>[src]

Returns the value of the SO_ERROR option.

Examples

use romio::uds::UnixStream;
use romio::raw::TakeError;

let stream = UnixStream::connect("/tmp/sock").await?;
if let Ok(Some(err)) = stream.take_error() {
    println!("Got error: {:?}", err);
}
Loading content...