RawIoBuf

Struct RawIoBuf 

Source
pub struct RawIoBuf { /* private fields */ }
Expand description

Raw I/O buffer (Non-owning, Copy) 原始 I/O 缓冲区(不持有所有权,可复制)

For Buffer Pool Arena mode. Implements Copy for ergonomic async IO. 用于 Buffer Pool Arena 模式,实现 Copy 便于异步 IO

Implementations§

Source§

impl RawIoBuf

Source

pub const unsafe fn new(ptr: *mut u8, cap: usize) -> Self

Create new raw buffer wrapper

§Safety

ptr must be valid and aligned for Direct I/O

Source

pub const fn with_len(self, len: usize) -> Self

Set length (chainable) / 设置长度(链式调用)

Source

pub const unsafe fn from_raw_parts( ptr: NonNull<u8>, len: usize, cap: usize, ) -> Self

Create from raw parts / 从原始部分创建

§Safety

ptr must be valid and aligned for Direct I/O

Source

pub fn from_slice(slice: &mut [u8]) -> Self

Create from mutable slice / 从可变切片创建

Source

pub unsafe fn slice(self, offset: usize, len: usize) -> Self

Slice for reading (len = 0, waiting for IO to fill) 切片用于读取(len = 0,等待 IO 填充)

§Safety
  1. offset + len must not exceed capacity
  2. offset must be aligned for Direct I/O
Source

pub unsafe fn slice_data(self, offset: usize, len: usize) -> Self

Slice for writing (len = cap, contains data) 切片用于写入(len = cap,包含待写数据)

§Safety
  1. offset + len must not exceed capacity
  2. offset must be aligned for Direct I/O
Source

pub unsafe fn slice_unchecked(self, offset: usize, len: usize) -> Self

Slice unchecked (extreme performance) / 无检查切片(极致性能)

§Safety

Caller MUST ensure bounds and alignment

Source

pub const fn len(&self) -> usize

Source

pub const fn cap(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Source

pub const fn as_ptr(&self) -> *const u8

Source

pub const fn as_mut_ptr(&self) -> *mut u8

Source

pub fn as_slice(&self) -> &[u8]

Source

pub fn as_mut_slice(&mut self) -> &mut [u8]

Source

pub unsafe fn set_len(&mut self, len: usize)

Set length

§Safety

Caller must ensure data is initialized up to len

Trait Implementations§

Source§

impl Clone for RawIoBuf

Source§

fn clone(&self) -> RawIoBuf

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RawIoBuf

Source§

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

Formats the value using the given formatter. Read more
Source§

impl IoBuf for RawIoBuf

Source§

fn as_buf_ptr(&self) -> *const u8

Returns a raw pointer to the vector’s buffer. Read more
Source§

fn buf_len(&self) -> usize

Number of initialized bytes. Read more
Source§

fn buf_capacity(&self) -> usize

Total size of the buffer, including uninitialized memory, if any. Read more
Source§

fn as_slice(&self) -> &[u8]

Get the initialized part of the buffer.
Source§

unsafe fn as_io_slice(&self) -> IoSlice

Create an IoSlice of this buffer. Read more
Source§

unsafe fn as_io_buffer(&self) -> IoBuffer

Create an IoBuffer of this buffer. Read more
Source§

fn slice(self, range: impl RangeBounds<usize>) -> Slice<Self>
where Self: Sized,

Returns a view of the buffer with the specified range. Read more
Source§

fn uninit(self) -> Uninit<Self>
where Self: Sized,

Returns an Uninit, which is a Slice that only exposes uninitialized bytes. Read more
Source§

fn filled(&self) -> bool

Indicate whether the buffer has been filled (uninit portion is empty)
Source§

impl IoBufMut for RawIoBuf

Source§

fn as_buf_mut_ptr(&mut self) -> *mut u8

Returns a raw mutable pointer to the vector’s buffer. Read more
Source§

fn as_mut_slice(&mut self) -> &mut [MaybeUninit<u8>]

Get the uninitialized part of the buffer.
Source§

unsafe fn as_io_slice_mut(&mut self) -> IoSliceMut

Create an IoSliceMut of the uninitialized part of the buffer. Read more
Source§

impl SetBufInit for RawIoBuf

Source§

unsafe fn set_buf_init(&mut self, len: usize)

Set the buffer length. If len is less than the current length, nothing should happen. Read more
Source§

impl Copy for RawIoBuf

Source§

impl Send for RawIoBuf

Source§

impl Sync for RawIoBuf

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.