Skip to main content

Crate lio

Crate lio 

Source
Expand description

§Lio - Low-Level Async I/O Library

Lio is a non-blocking, platform-independent, zero-copy (when possible) I/O library that provides control back to the user. It does so by giving raw access to the syscall arguments, which it then builds upon. For example Lio (optionally) can manage buffers in a zero-copy way, and can integrate with zeroize.

It uses the most efficient I/O available based on OS. It uses:

  • Linux: io_uring, epoll as backup.
  • BSD/Apple: kqueue.
  • Windows: I/O Completion Ports.

As lio is platform-independent, it needs to abstract over OS resources like files/sockets. lio calls these resources. Resources are reference counted OS-native identifiers (fd’s/handles/etc), which means that cloning is cheap. lio will automatically drop/close these on the last reference’s drop.

§Example

All operations return a Io<T> which represents an in-flight I/O operation:

use lio::{Lio, api};

let mut lio = Lio::new(64).unwrap();
let resource = api::resource::Resource::stdout();
let data = b"Hello\n".to_vec();

// Callback-based
api::write(&resource, data).with_lio(&mut lio).when_done(|(result, buf)| {
    // result: io::Result<i32>, buf: the original Vec
});
lio.try_run().unwrap();

Re-exports§

pub use buf::BufResult;

Modules§

api
lio’s low-level I/O API.
backends
I/O backend implementations for lio.
buf
Buffer abstractions for zero-copy I/O operations.
ffiunstable_ffi
lio C API
fs
net
Async networking primitives for lio.
op
Operation data enum for zero-box I/O operations.
typed_op
Type-safe operation trait for Op enum integration.

Structs§

Lio

Functions§

install_global
Installs a global Lio instance for the current thread.
uninstall_global
Uninstalls the global Lio instance for the current thread.