[][src]Enum ffimage::packed::image::dynamic::MemoryBuffer

pub enum MemoryBuffer {
    U8(Vec<u8>),
    U16(Vec<u16>),
}

Runtime memory buffer

Variants

U8(Vec<u8>)
U16(Vec<u16>)

Implementations

impl MemoryBuffer[src]

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

Returns the slice representation of a memory buffer

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

Example

use ffimage::packed::{DynamicImageBuffer, DynamicStorageType};

let buf = DynamicImageBuffer::new(2, 2, 3, DynamicStorageType::U8);

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

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

Returns the mutable slice representation of a memory buffer

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

Example

use ffimage::packed::{DynamicImageBuffer, DynamicStorageType};

let mut buf = DynamicImageBuffer::new(2, 2, 3, DynamicStorageType::U8);

let slice: &[u8] = buf.raw_mut().as_mut_slice()
    .expect("Failed to cast memory buffer");

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

Returns the number of elements in the buffer

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

Returns true if there are no elements in the buffer

Trait Implementations

impl<T: 'static> TryFrom<Vec<T>> for MemoryBuffer[src]

type Error = ()

The type returned in the event of a conversion error.

Auto Trait Implementations

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.