Trait conch_runtime::os::unix::io::FileDescExt [] [src]

pub trait FileDescExt {
    fn into_evented(
        self,
        handle: &Handle
    ) -> Result<PollEvented<EventedFileDesc>>;
fn set_nonblock(&self, set: bool) -> Result<()>; fn into_evented2(self, handle: &Handle) -> Result<MaybeEventedFd>
    where
        Self: Sized
, { ... } }

Unix-specific extensions for a FileDesc.

To make use of this extension, make sure this trait is imported into the appropriate module.

extern crate conch_runtime;

use conch_runtime::io::FileDesc;
use conch_runtime::os::unix::io::FileDescExt;

let file = File::open("/dev/null").unwrap();
let fd = FileDesc::from(file);

let core = Core::new().unwrap();
fd.into_evented(&core.handle()).unwrap();

Required Methods

Deprecated

: does not handle regular files, use into_evented2 instead

Registers the underlying primitive OS handle with a tokio event loop.

The resulting type is "futures" aware meaning that it is (a) nonblocking, (b) will notify the appropriate task when data is ready to be read or written and (c) will panic if use off of a future's task.

Note: two identical file descriptors (which have identical file descriptions) must NOT be registered on the same event loop at the same time (e.g. unsafely coping raw file descriptors and registering both copies with the same Handle). Doing so may end up starving one of the copies from receiving notifications from the event loop.

Sets the O_NONBLOCK flag on the descriptor to the desired state.

Specifiying true will set the file descriptor in non-blocking mode, while specifying false will set it to blocking mode.

Provided Methods

Attempts to register the underlying primitive OS handle with a tokio event loop.

The resulting type is "futures" aware meaning that it is (a) nonblocking, (b) will notify the appropriate task when data is ready to be read or written and (c) will panic if use off of a future's task.

Note: two identical file descriptors (which have identical file descriptions) must NOT be registered on the same event loop at the same time (e.g. unsafely coping raw file descriptors and registering both copies with the same Handle). Doing so may end up starving one of the copies from receiving notifications from the event loop.

Note: regular files are not supported by the OS primitives which power tokio event loops, and will result in an error on registration. However, since regular files can be assumed to always be ready for read/write operations, we can handle this usecase by not registering those file descriptors within tokio.

Implementors