ByteBuffer

Struct ByteBuffer 

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

异步字节缓冲区

Implementations§

Source§

impl ByteBuffer

Source

pub fn new(stream: BoxReceiver<'static, Arc<Vec<u8>>>) -> Self

创建一个异步字节缓冲区

Source

pub fn is_terminated(&self) -> bool

获取当前流是否已终止

Source

pub fn is_empty(&self) -> bool

判断当前缓冲区是否为空

Source

pub fn len(&self) -> usize

获取当前缓冲区包含的所有字节长度

Source

pub fn remaining(&self) -> usize

获取当前缓冲区剩余可读字节长度

Source

pub fn unreceived(&self) -> Option<usize>

流中已发送未接收的数据条目长度

Source

pub fn readed(&self) -> usize

清理前已读字节的总数量

Source

pub async fn get_i8(&mut self) -> Option<i8>

异步获取一个i8

Source

pub async fn get_u8(&mut self) -> Option<u8>

异步获取一个u8

Source

pub async fn get_i16(&mut self) -> Option<i16>

异步获取一个大端i16

Source

pub async fn get_i16_le(&mut self) -> Option<i16>

异步获取一个小端i16

Source

pub async fn get_u16(&mut self) -> Option<u16>

异步获取一个大端u16

Source

pub async fn get_u16_le(&mut self) -> Option<u16>

异步获取一个小端u16

Source

pub async fn get_i32(&mut self) -> Option<i32>

异步获取一个大端i32

Source

pub async fn get_i32_le(&mut self) -> Option<i32>

异步获取一个小端i32

Source

pub async fn get_u32(&mut self) -> Option<u32>

异步获取一个大端u32

Source

pub async fn get_u32_le(&mut self) -> Option<u32>

异步获取一个小端u32

Source

pub async fn get_i64(&mut self) -> Option<i64>

异步获取一个大端i64

Source

pub async fn get_i64_le(&mut self) -> Option<i64>

异步获取一个小端i64

Source

pub async fn get_u64(&mut self) -> Option<u64>

异步获取一个大端u64

Source

pub async fn get_u64_le(&mut self) -> Option<u64>

异步获取一个小端u64

Source

pub async fn get_i128(&mut self) -> Option<i128>

异步获取一个大端i128

Source

pub async fn get_i128_le(&mut self) -> Option<i128>

异步获取一个小端i128

Source

pub async fn get_u128(&mut self) -> Option<u128>

异步获取一个大端u128

Source

pub async fn get_u128_le(&mut self) -> Option<u128>

异步获取一个小端u128

Source

pub async fn get_isize(&mut self) -> Option<isize>

异步获取一个大端isize

Source

pub async fn get_isize_le(&mut self) -> Option<isize>

异步获取一个小端isize

Source

pub async fn get_usize(&mut self) -> Option<usize>

异步获取一个大端usize

Source

pub async fn get_usize_le(&mut self) -> Option<usize>

异步获取一个小端usize

Source

pub async fn get_f32(&mut self) -> Option<f32>

异步获取一个大端f32

Source

pub async fn get_f32_le(&mut self) -> Option<f32>

异步获取一个小端f32

Source

pub async fn get_f64(&mut self) -> Option<f64>

异步获取一个大端f64

Source

pub async fn get_f64_le(&mut self) -> Option<f64>

异步获取一个小端f64

Source

pub async fn get(&mut self, len: usize) -> Option<PartBuffer>

异步获取指定长度的部分缓冲区

Source

pub async fn try_get(&mut self, len: usize) -> Option<PartBuffer>

尝试异步获取指定长度的部分缓冲区, 此方法保证不会导致异步阻塞,同时此方法也不保证一定可以获取到不小于指定长度的部分缓冲区 当指定获取的字节数量为0,表示尝试获取当前流和当前缓冲区中所有剩余的未读字节

Source

pub async fn try_fill(&mut self) -> usize

尝试异步接收流中的所有字节,并填充到当前缓冲区,返回接收后缓冲区剩余可读字节数 此方法保证不会导致异步阻塞

Source

pub fn truncate(&mut self) -> usize

截断当前所有已读缓冲区 这会释放已读缓冲区的内存,并重置已读字节的总数量

Source

pub fn clear(&mut self)

清空当前缓冲区 这会释放当前缓冲区的所有内存,并重置已读字节的总数量

Trait Implementations§

Source§

impl AsRef<[u8]> for ByteBuffer

Source§

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

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Send for ByteBuffer

Source§

impl !Sync for ByteBuffer

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> 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ThreadSend for T
where T: Send,