Struct flatdata::ArrayView[][src]

pub struct ArrayView<'a, T: 'a> { /* fields omitted */ }

A read-only view on a contiguous sequence of flatdata structs of the same type T.

The sequence is written using Vector or ExternalVector. The former provides a method to create an ArrayView to it. Note that, that an array view does not hold the data itself.

An archive provides a getter for each vector resource, which returns an array view.

Examples

use flatdata::{ArrayView, Vector};

define_struct!(A, AMut, "no_schema", 4,
    (x, set_x, u32, 0, 16),
    (y, set_y, u32, 16, 16)
);

let mut v: Vector<A> = Vector::with_len(1);
{
    let mut a = v.at_mut(0);
    a.set_x(1);
    a.set_y(2);
}

let view: ArrayView<_> = v.as_view();
let a = view.at(0);
assert_eq!(a.x(), 1);
assert_eq!(a.y(), 2);

Methods

impl<'a, T: Struct> ArrayView<'a, T>
[src]

Creates a new ArrayView to the data at the given address.

The returned array view does not own the data.

Number of elements in the array.

Return true if the array is empty.

Returns a read-only handle to the element in the array at position index.

Panics

Panics if index is greater than or equal to ArrayView::len().

Returns an iterator to the elements of the array.

Returns a raw bytes representation of the underlying array data.

Trait Implementations

impl<'a, T: Clone + 'a> Clone for ArrayView<'a, T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a, T: Struct> Debug for ArrayView<'a, T>
[src]

Formats the value using the given formatter. Read more

impl<'a, T: Struct> AsRef<[u8]> for ArrayView<'a, T>
[src]

Performs the conversion.

Auto Trait Implementations

impl<'a, T> Send for ArrayView<'a, T> where
    T: Send

impl<'a, T> Sync for ArrayView<'a, T> where
    T: Sync