[−][src]Enum ffimage::packed::dynamic::MemoryBuffer
Runtime memory buffer
Variants
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 std::convert::TryFrom; use ffimage::packed::dynamic::{MemoryBuffer, StorageType}; let mut mem: Vec<u8> = vec![0; 12]; let buf = MemoryBuffer::try_from(mem) .expect("Failed to wrap memory region"); let slice: &[u8] = buf.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 std::convert::TryFrom; use ffimage::packed::dynamic::{MemoryBuffer, StorageType}; let mut mem: Vec<u8> = vec![0; 12]; let mut buf = MemoryBuffer::try_from(mem) .expect("Failed to wrap memory region"); let slice: &mut [u8] = buf.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<'a, '_> From<&'_ MemoryView<'a>> for MemoryBuffer
[src]
fn from(view: &MemoryView<'a>) -> Self
[src]
impl<T: 'static> TryFrom<Vec<T>> for MemoryBuffer
[src]
Auto Trait Implementations
impl RefUnwindSafe for MemoryBuffer
impl Send for MemoryBuffer
impl Sync for MemoryBuffer
impl Unpin for MemoryBuffer
impl UnwindSafe for MemoryBuffer
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,