Trait timeout_io::ReadableSliceQueue [−][src]
pub trait ReadableSliceQueue<T> { fn len(&self) -> usize; fn is_empty(&self) -> bool; fn peek(&self) -> Option<&T>; fn peek_n(&self, n: usize) -> Result<&[T], &[T]>; fn pop(&mut self) -> Result<T, ()>; fn pop_n(&mut self, n: usize) -> Result<Vec<T>, Vec<T>>; fn pop_into(&mut self, dst: &mut [T]) -> Result<(), usize>; fn drop_n(&mut self, n: usize) -> Result<(), usize>; }
Required Methods
fn len(&self) -> usize
The amount of elements stored
Returns the amount of elements stored in self
fn is_empty(&self) -> bool
Checks if there are no elements stored
Returns either true
if self
is empty or false
otherwise
fn peek(&self) -> Option<&T>
Take a look at the first element without consuming it
Returns either Some(element_ref)
if we have a first element or None
otherwise
fn peek_n(&self, n: usize) -> Result<&[T], &[T]>
Take a look at the first n
elements without consuming them
Parameters:
n
: The amount of elements to peek at
Returns either Ok(element_refs)
if there were n
elements avaliable to peek at or
Err(element_refs)
if less elements were available
fn pop(&mut self) -> Result<T, ()>
Consumes the first element and returns it
Returns either Ok(element)
if there was an element to consume or Err(())
otherwise
fn pop_n(&mut self, n: usize) -> Result<Vec<T>, Vec<T>>
Consumes the first n
elements and returns them
Parameters:
n
: The amount of elements to consume
Returns either Ok(elements)
if there were n
elements avaliable to consume or
Err(elements)
if less elements were available
fn pop_into(&mut self, dst: &mut [T]) -> Result<(), usize>
Consumes the first dst.len()
and moves them into dst
Parameters:
dst
: The target to move the elements into
Returns either Ok(())
if dst
was filled completely or Err(element_count)
if
only element_count
elements were moved
fn drop_n(&mut self, n: usize) -> Result<(), usize>
Discards the first n
elements
Parameters:
n
: The amount of elements to discard
Returns either Ok(())
if n
elements were discarded or Err(element_count)
if
only element_count
elements were discarded
Implementors
impl<T> ReadableSliceQueue<T> for SliceQueue<T>