[−][src]Struct byte_array::ByteArray
An object that can read and store time series data.
Examples
use byte_array::ByteArray; let mut ba = ByteArray::new(); // Write ba <<= &3.14; ba.write(&(1234 as u16)); // Read ba.seek_first(); assert_eq!(3.14, ba.read::<f64>()); assert_eq!(1234, ba.read_safe::<u16>().unwrap());
Methods
impl ByteArray
[src]
pub fn new() -> Self
[src]
Creates an empty ByteArray
.
pub fn read<T>(&mut self) -> T where
T: BinaryBuilder,
[src]
T: BinaryBuilder,
Gets the data of the specified type in the ByteArray
.
But, the data to be read must implement BinaryBuilder
trait.
Panics
Panics when unexpected EOF.
pub fn read_safe<T>(&mut self) -> Option<T> where
T: BinaryBuilder,
[src]
T: BinaryBuilder,
Gets the data of the specified type in the ByteArray
safely.
But, the data to be read must implement BinaryBuilder
trait.
pub fn write<T>(&mut self, value: &T) where
T: BinaryBuilder,
[src]
T: BinaryBuilder,
Adds data to the ByteArray
.
But, the data to be read must implement BinaryBuilder
trait.
pub fn seek_first(&mut self)
[src]
Starts reading the data stored in the ByteArray
from the beginning.
pub fn seek_last(&mut self)
[src]
Makes the ByteArray
ready for adding data.
pub fn seek_next(&mut self, stride: usize) -> Option<()>
[src]
Skips as many bytes as you want safely.
pub fn as_vec(&mut self) -> &mut Vec<u8>
[src]
Gets the actual data stored in the ByteArray
.
pub fn len(&self) -> usize
[src]
Gets the number of bytes of data stored in the ByteArray
.
pub fn bytes_available(&self) -> usize
[src]
Gets the byte distance from the end of the data to the current read.
pub const fn now(&self) -> usize
[src]
Gets the byte distance from the start of the data to the current read.
Trait Implementations
impl BinaryBuilder for ByteArray
[src]
fn new() -> Self
[src]
fn from_raw(ba: &mut ByteArray) -> Option<Self>
[src]
fn to_raw(&self, ba: &mut Self)
[src]
impl<'a, T> ShlAssign<&'a T> for ByteArray where
T: BinaryBuilder,
[src]
T: BinaryBuilder,
fn shl_assign(&mut self, rhs: &'a T)
[src]
impl<'a, T, '_> ShlAssign<&'a T> for &'_ mut ByteArray where
T: BinaryBuilder,
[src]
T: BinaryBuilder,
fn shl_assign(&mut self, rhs: &'a T)
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,