[][src]Enum ffimage::packed::dynamic::MemoryView

pub enum MemoryView<'a> {
    U8(&'a [u8]),
    U16(&'a [u16]),
}

Runtime memory view

Variants

Implementations

impl<'a> MemoryView<'a>[src]

pub fn as_slice<T: 'static>(&self) -> Option<&[T]>[src]

Returns the slice representation of a memory view

It is ensured that only the proper type representation can be cast from the underlying view. If, for example, you were to call the method on a U16 view and try to get a u8 slice reference, the function would return None instead.

Example

use std::convert::TryFrom;
use ffimage::packed::dynamic::MemoryView;

let mem: Vec<u8> = vec![0; 12];
let view = MemoryView::try_from(&mem[..])
    .expect("Failed to wrap memory region");

let slice: &[u8] = view.as_slice()
    .expect("Failed to cast memory view");

pub fn len(&self) -> usize[src]

Returns the number of elements in the view

pub fn is_empty(&self) -> bool[src]

Returns true if there are no elements in the view

Trait Implementations

impl<'a, '_> From<&'_ MemoryView<'a>> for MemoryBuffer[src]

impl<'a, T: 'static, '_> TryFrom<&'_ [T]> for MemoryView<'a>[src]

type Error = ()

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<'a> RefUnwindSafe for MemoryView<'a>

impl<'a> Send for MemoryView<'a>

impl<'a> Sync for MemoryView<'a>

impl<'a> Unpin for MemoryView<'a>

impl<'a> UnwindSafe for MemoryView<'a>

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.