pub trait DataBuf: AsMut<[Self::Inner]> + AsRef<[Self::Inner]> {
type Inner: Pod;
fn extend(&mut self, len: usize) -> Result<(), ()>;
fn round_to_words(bytes: usize) -> usize { ... }
}
Expand description
Trait used to represent a data buffer, typically you’ll passs a [usize; N]
array.
Can also provide a Vec<T>
(if the alloc
feature is enabled) which will grow as-needed
Associated Types
Required methods
Provided methods
fn round_to_words(bytes: usize) -> usize
fn round_to_words(bytes: usize) -> usize
Convert a byte count to a word count (rounding up)
Implementations on Foreign Types
sourceimpl<T: Pod> DataBuf for Vec<T>
impl<T: Pod> DataBuf for Vec<T>
Vector backed structures, can be used to auto-grow the allocation
let mut buf = ::stack_dst::FifoA::<str, Vec<u8>>::new();
buf.push_back_str("Hello world!");
buf.push_back_str("This is a very long string");
buf.push_back_str("The buffer should keep growing as it needs to");
for line in buf.iter() {
println!("{}", line);
}