Skip to main content

SubmitEntry

Struct SubmitEntry 

Source
pub struct SubmitEntry {
    pub fd: i32,
    pub opcode: u8,
    pub flags: u16,
    pub user_data: u64,
    pub buf_ptr: Option<NonNull<u8>>,
    pub buf_len: u32,
    pub offset: u64,
    pub addr: Option<SockAddr>,
}
Expand description

Submission queue entry 提交队列条目

Represents a single I/O operation to be submitted to the kernel. 表示要提交给内核的单个I/O操作。

§Safety / 安全性

  • buf_ptr must be valid for buf_len bytes if non-null
  • The buffer must remain valid until the operation completes
  • 如果非空,buf_ptr 必须对 buf_len 字节有效
  • 缓冲区必须在操作完成前保持有效

Fields§

§fd: i32

File descriptor to operate on / 操作的文件描述符

§opcode: u8

Operation opcode (READ, WRITE, etc.) / 操作操作码

§flags: u16

Operation flags / 操作标志

§user_data: u64

User data for completion correlation (opaque pointer) 用于完成关联的用户数据(不透明指针)

§buf_ptr: Option<NonNull<u8>>

Buffer pointer / 缓冲区指针

§buf_len: u32

Buffer length in bytes / 缓冲区长度(字节)

§offset: u64

Offset for file operations / 文件操作的偏移量

§addr: Option<SockAddr>

Address for connect/accept operations / 连接/接受操作的地址

Implementations§

Source§

impl SubmitEntry

Source

pub const fn new(fd: i32, opcode: u8, user_data: u64) -> Self

Create a new submission entry 创建新的提交条目

Source

pub unsafe fn read(fd: i32, buf: *mut u8, buf_len: u32, user_data: u64) -> Self

Create a read operation entry 创建读操作条目

§Safety / 安全性

buf must be valid for reads and remain valid until completion. buf 必须对读取有效并在完成前保持有效。

Source

pub unsafe fn write( fd: i32, buf: *const u8, buf_len: u32, user_data: u64, ) -> Self

Create a write operation entry 创建写操作条目

§Safety / 安全性

buf must be valid for reads and remain valid until completion. buf 必须对读取有效并在完成前保持有效。

Source

pub unsafe fn with_buffer(self, buf: *mut u8, buf_len: u32) -> Self

Set the buffer for this operation 为此操作设置缓冲区

§Safety / 安全性

buf must be valid for buf_len bytes. buf 必须对 buf_len 字节有效。

Source

pub const fn with_offset(self, offset: u64) -> Self

Set the offset for file operations 为文件操作设置偏移量

Source

pub const fn with_flags(self, flags: u16) -> Self

Set operation flags 设置操作标志

Source

pub fn with_addr(self, addr: SockAddr) -> Self

Set socket address for connect/accept 为connect/accept设置套接字地址

Source

pub unsafe fn buffer(&self) -> Option<&[u8]>

Get the buffer as a slice if available 如果可用,获取缓冲区的切片

§Safety / 安全性

The returned slice is only valid if the buffer is still alive. 返回的切片仅在缓冲区仍然存活时有效。

Source

pub unsafe fn buffer_mut(&self) -> Option<&mut [u8]>

Get the buffer as a mutable slice if available 如果可用,获取缓冲区的可变切片

§Safety / 安全性

The returned slice is only valid if the buffer is still alive and mutable. 返回的切片仅在缓冲区仍然存活且可变时有效。

Trait Implementations§

Source§

impl Clone for SubmitEntry

Source§

fn clone(&self) -> SubmitEntry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SubmitEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.