[][src]Struct byte_array::ByteArray

pub struct ByteArray { /* fields omitted */ }

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]

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]

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]

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]

impl<'a, T> ShlAssign<&'a T> for ByteArray where
    T: BinaryBuilder
[src]

impl<'a, T, '_> ShlAssign<&'a T> for &'_ mut ByteArray where
    T: BinaryBuilder
[src]

Auto Trait Implementations

impl Send for ByteArray

impl Sync for ByteArray

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]