pub struct Buffer<T>{ /* private fields */ }Implementations§
Source§impl<T> Buffer<T>
impl<T> Buffer<T>
Sourcepub fn new(source: T) -> Buffer<T>
pub fn new(source: T) -> Buffer<T>
Create a new buffer from any source
§Example
use buffer::Buffer;
let mut bytes = [0; 1024];
let mut buffer = Buffer::new(&mut bytes);Sourcepub fn remaining_capacity(&self) -> usize
pub fn remaining_capacity(&self) -> usize
Returns the remaining space that can be written
This method does not perform a Buffer::shift
Sourcepub fn has_remaining_capacity(&self) -> bool
pub fn has_remaining_capacity(&self) -> bool
returns if there is remaining
is equal to Buffer::remaining_capacity() > 0
Sourcepub fn remaining_len(&self) -> usize
pub fn remaining_len(&self) -> usize
Returns the remaining bayes to read
pub fn has_remaining_len(&self) -> bool
Sourcepub fn has_dead_capacity(&self) -> bool
pub fn has_dead_capacity(&self) -> bool
Returns true if the read position is > 0
Sourcepub fn ensure_remaining_capacity(&mut self) -> bool
pub fn ensure_remaining_capacity(&mut self) -> bool
Performa s Buffer::shift if there is no remianing capacity and
returns if there is remainig capacity afterwards
pub fn create_reader_with_max(&mut self, max_bytes: usize) -> Reader<'_, T>
Sourcepub fn push(&mut self, buf: &[u8]) -> Result<(), BufferError>
pub fn push(&mut self, buf: &[u8]) -> Result<(), BufferError>
Appends the provided slice to the buffer a a whole
§Error
BufferError::NoCapacity if buf.len() > self.remaining_capacity()
Trait Implementations§
Source§impl<T> Read for Buffer<T>
impl<T> Read for Buffer<T>
Source§fn read(
&mut self,
buf: &mut [u8],
) -> Result<usize, <Buffer<T> as ErrorType>::Error>
fn read( &mut self, buf: &mut [u8], ) -> Result<usize, <Buffer<T> as ErrorType>::Error>
Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
Read the exact number of bytes required to fill
buf. Read moreSource§impl<T> ReadWrite for Buffer<T>
impl<T> ReadWrite for Buffer<T>
fn create_reader<'a>(&'a mut self) -> impl BufferReader + 'a
fn create_writer<'a>(&'a mut self) -> impl BufferWriter + 'a
Source§impl<T> Write for Buffer<T>
impl<T> Write for Buffer<T>
Source§fn write(
&mut self,
buf: &[u8],
) -> Result<usize, <Buffer<T> as ErrorType>::Error>
fn write( &mut self, buf: &[u8], ) -> Result<usize, <Buffer<T> as ErrorType>::Error>
Write a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<(), <Buffer<T> as ErrorType>::Error>
fn flush(&mut self) -> Result<(), <Buffer<T> as ErrorType>::Error>
Flush this output stream, blocking until all intermediately buffered contents reach their destination.
Auto Trait Implementations§
impl<T> Freeze for Buffer<T>where
T: Freeze,
impl<T> RefUnwindSafe for Buffer<T>where
T: RefUnwindSafe,
impl<T> Send for Buffer<T>where
T: Send,
impl<T> Sync for Buffer<T>where
T: Sync,
impl<T> Unpin for Buffer<T>where
T: Unpin,
impl<T> UnwindSafe for Buffer<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more