Skip to main content

Module operation

Module operation 

Source
Expand description

io_uring operations

This module defines all supported io_uring operations. Each operation implements the UringOperation trait which allows it to be submitted to an io_uring instance.

§Safety

All operations contain raw pointers and file descriptors. When submitting operations, you must ensure that:

  • All pointers remain valid until the operation completes
  • Buffers are not accessed mutably while operations are in flight
  • File descriptors remain valid until operations complete

§Examples

use lio_uring::{LioUring, operation::Write};
use std::os::fd::AsRawFd;

let mut ring = LioUring::new(32)?;

let data = b"Hello, io_uring!";
let file = std::fs::File::create("/tmp/test")?;

let op = Write::new(file.as_raw_fd(), data.as_ptr(), data.len() as u32);

unsafe { ring.push(op.build(), 1) }?;
ring.submit()?;

let completion = ring.wait()?;
assert_eq!(completion.result(), data.len() as i32);

Structs§

Accept
Accept a new connection on a socket, equivalent to accept4(2).
AcceptMulti
Accept multiple new connections on a socket.
AsyncCancel
Attempt to cancel an already issued request.
Bind
Bind a socket, equivalent to bind(2).
Close
Close a file descriptor, equivalent to close(2).
Connect
Connect a socket, equivalent to connect(2).
EpollCtl
Modify an epoll file descriptor, equivalent to epoll_ctl(2).
EpollWait
Issue the equivalent of a epoll_wait(2) system call.
FGetXattr
Get extended attribute from a file descriptor, equivalent to fgetxattr(2).
FSetXattr
Set extended attribute on a file descriptor, equivalent to fsetxattr(2).
Fadvise
Predeclare an access pattern for file data, equivalent to posix_fadvise(2).
Fallocate
Preallocate or deallocate space to a file, equivalent to fallocate(2).
FilesUpdate
This command is an alternative to using Submitter::register_files_update which then works in an async fashion, like the rest of the io_uring commands.
Fsync
File sync, equivalent to fsync(2).
FsyncFlags
Options for Fsync.
Ftruncate
Perform file truncation, equivalent to ftruncate(2).
FutexWait
Wait on a futex, like but not equivalant to futex(2)’s FUTEX_WAIT_BITSET.
FutexWake
Wake up waiters on a futex, like but not equivalant to futex(2)’s FUTEX_WAKE_BITSET.
GetXattr
Get extended attribute, equivalent to getxattr(2).
LinkAt
Create a hard link, equivalent to linkat(2).
LinkTimeout
This request must be linked with another request through Flags::IO_LINK which is described below. Unlike Timeout, LinkTimeout acts on the linked request, not the completion queue.
Listen
Listen on a socket, equivalent to listen(2).
Madvise
Give advice about use of memory, equivalent to madvise(2).
MkDirAt
Make a directory, equivalent to mkdirat(2).
Nop
Do not perform any I/O.
OpenAt
Open a file, equivalent to openat(2).
Pipe
PollAdd
Poll the specified fd.
PollRemove
Remove an existing poll request.
ProvideBuffers
Register nbufs buffers that each have the length len with ids starting from bid in the group bgid that can be used for any request. See BUFFER_SELECT for more info.
Read
Issue the equivalent of a pread(2) or pwrite(2) system call
ReadFixed
Read from a file into a fixed buffer that has been previously registered with Submitter::register_buffers.
ReadMulti
Issue the equivalent of pread(2) with multi-shot semantics.
Readv
Vectored read, equivalent to preadv2(2).
ReadvFixed
Vectored read into a fixed buffer, equivalent to preadv2(2).
Recv
Receive a message from a socket, equivalent to recv(2).
RecvBundle
Receive a bundle of buffers from a socket.
RecvMsg
Receive a message on a socket, equivalent to recvmsg(2).
RecvMsgMulti
Receive multiple messages on a socket, equivalent to recvmsg(2).
RecvMulti
Receive multiple messages from a socket, equivalent to recv(2).
RecvMultiBundle
Receive multiple messages from a socket as a bundle.
RecvZc
Issue the zerocopy equivalent of a recv(2) system call.
RemoveBuffers
Remove some number of buffers from a buffer group. See BUFFER_SELECT for more info.
RenameAt
Send
Send a message on a socket, equivalent to send(2).
SendBundle
Send a bundle of messages on a socket in a single request.
SendMsg
Send a message on a socket, equivalent to send(2).
SendMsgZc
Send a zerocopy message on a socket, equivalent to send(2).
SendZc
Send a zerocopy message on a socket, equivalent to send(2).
SetXattr
Set extended attribute, equivalent to setxattr(2).
Shutdown
Shut down all or part of a full duplex connection on a socket, equivalent to shutdown(2). Available since kernel 5.11.
Socket
Create an endpoint for communication, equivalent to socket(2).
Splice
Splice data to/from a pipe, equivalent to splice(2).
Statx
Get file status, equivalent to statx(2).
SymlinkAt
Create a symlink, equivalent to symlinkat(2).
SyncFileRange
Sync a file segment with disk, equivalent to sync_file_range(2).
Tee
Duplicate pipe content, equivalent to tee(2).
Timeout
Register a timeout operation.
TimeoutFlags
TimeoutRemove
Attempt to remove an existing timeout operation.
TimeoutUpdate
Attempt to update an existing timeout operation with a new timespec. The optional count value of the original timeout value cannot be updated.
UnlinkAt
UringCmd16
A file/device-specific 16-byte command, akin (but not equivalent) to ioctl(2).
WaitId
Issue the equivalent of a waitid(2) system call.
Write
Issue the equivalent of a pread(2) or pwrite(2) system call
WriteFixed
Write to a file from a fixed buffer that have been previously registered with Submitter::register_buffers.
Writev
Vectored write, equivalent to pwritev2(2).
WritevFixed
Vectored write from a fixed buffer, equivalent to pwritev2(2).