PipeRingBuffer

Struct PipeRingBuffer 

Source
struct PipeRingBuffer {
    buffer: VecDeque<u8>,
    capacity: usize,
    write_end_count: usize,
    read_end_count: usize,
}
Expand description

管道环形缓冲区

容量默认 4KB(POSIX 最小 512 字节)。

Fields§

§buffer: VecDeque<u8>

内部缓冲区

§capacity: usize

缓冲区容量

§write_end_count: usize

写端引用计数 (用于检测写端关闭)

§read_end_count: usize

读端引用计数 (用于检测读端关闭)

Implementations§

Source§

impl PipeRingBuffer

Source

const DEFAULT_CAPACITY: usize = 4_096usize

Source

const MIN_CAPACITY: usize = 4_096usize

Source

const MAX_CAPACITY: usize = 1_048_576usize

Source

fn new() -> Self

Source

fn get_capacity(&self) -> usize

获取管道容量

Source

fn set_capacity(&mut self, new_capacity: usize) -> Result<(), FsError>

设置管道容量

Source

fn read(&mut self, buf: &mut [u8]) -> Result<usize, FsError>

读取数据 (非阻塞)

Source

fn write(&mut self, buf: &[u8]) -> Result<usize, FsError>

写入数据 (非阻塞)

Auto Trait Implementations§

§

impl Freeze for PipeRingBuffer

§

impl RefUnwindSafe for PipeRingBuffer

§

impl Send for PipeRingBuffer

§

impl Sync for PipeRingBuffer

§

impl Unpin for PipeRingBuffer

§

impl UnwindSafe for PipeRingBuffer

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.