pub trait IoBufExt: IoBuf {
// Provided methods
fn buf_len(&self) -> usize { ... }
fn buf_ptr(&self) -> *const u8 { ... }
fn is_empty(&self) -> bool { ... }
fn slice(self, range: impl RangeBounds<usize>) -> Slice<Self>
where Self: Sized { ... }
fn into_reader(self) -> Reader<Self> ⓘ
where Self: Sized { ... }
fn as_reader(&self) -> ReaderRef<'_, Self> ⓘ { ... }
}Expand description
Extension trait for immutable buffers.
Provided Methods§
Sourcefn slice(self, range: impl RangeBounds<usize>) -> Slice<Self>where
Self: Sized,
fn slice(self, range: impl RangeBounds<usize>) -> Slice<Self>where
Self: Sized,
Returns a view of the buffer with the specified range.
This method is similar to Rust’s slicing (&buf[..]), but takes
ownership of the buffer.
§Examples
use compio_buf::{IoBuf, IoBufExt};
let buf = b"hello world";
assert_eq!(buf.slice(6..).as_init(), b"world");§Panics
Panics if:
- begin > buf_len()
- end < begin
Sourcefn into_reader(self) -> Reader<Self> ⓘwhere
Self: Sized,
fn into_reader(self) -> Reader<Self> ⓘwhere
Self: Sized,
Create a Reader from this buffer, which implements
std::io::Read.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".