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]
impl<'a, T: Struct> ArrayView<'a, T>
pub fn new(mem_descr: &MemoryDescriptor) -> Self
[src]
pub fn new(mem_descr: &MemoryDescriptor) -> Self
Creates a new ArrayView
to the data at the given address.
The returned array view does not own the data.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Number of elements in the array.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Return true
if the array is empty.
pub fn at(&self, index: usize) -> Handle<'a, T>
[src]
pub fn at(&self, index: usize) -> Handle<'a, T>
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()
.
pub fn iter(&'a self) -> ArrayViewIter<T>
[src]
pub fn iter(&'a self) -> ArrayViewIter<T>
Returns an iterator to the elements of the array.
pub fn as_bytes(&self) -> &[u8]
[src]
pub fn as_bytes(&self) -> &[u8]
Returns a raw bytes representation of the underlying array data.
Trait Implementations
impl<'a, T: Clone + 'a> Clone for ArrayView<'a, T>
[src]
impl<'a, T: Clone + 'a> Clone for ArrayView<'a, T>
fn clone(&self) -> ArrayView<'a, T>
[src]
fn clone(&self) -> ArrayView<'a, T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<'a, T: Struct> Debug for ArrayView<'a, T>
[src]
impl<'a, T: Struct> Debug for ArrayView<'a, T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'a, T: Struct> AsRef<[u8]> for ArrayView<'a, T>
[src]
impl<'a, T: Struct> AsRef<[u8]> for ArrayView<'a, T>