Struct symbolic_common::ByteViewHandle
[−]
[src]
pub struct ByteViewHandle<'bytes, T> { /* fields omitted */ }
A smart pointer for byte data that owns a derived object.
In some situations symbolic needs to deal with types that are based on potentially owned or borrowed bytes and wants to provide another view at them. This for instance is used when symbolic works with partially parsed files (like headers) of byte data.
Upon deref
the inner type is returned. Additionally the bytes
are exposed through the static get_bytes
method.
Methods
impl<'bytes, T> ByteViewHandle<'bytes, T>
[src]
fn from_byteview<F>(
view: ByteView<'bytes>,
f: F
) -> Result<ByteViewHandle<'bytes, T>> where
F: FnOnce(&'bytes [u8]) -> Result<T>,
[src]
view: ByteView<'bytes>,
f: F
) -> Result<ByteViewHandle<'bytes, T>> where
F: FnOnce(&'bytes [u8]) -> Result<T>,
Creates a new ByteViewHandle
from a ByteView
The closure is invoked with the borrowed bytes from the original byte view and the return value is retained in the handle.
fn from_slice<F>(
buffer: &'bytes [u8],
f: F
) -> Result<ByteViewHandle<'bytes, T>> where
F: FnOnce(&'bytes [u8]) -> Result<T>,
[src]
buffer: &'bytes [u8],
f: F
) -> Result<ByteViewHandle<'bytes, T>> where
F: FnOnce(&'bytes [u8]) -> Result<T>,
Constructs a ByteViewHandle
from a byte slice
fn from_vec<F>(vec: Vec<u8>, f: F) -> Result<ByteViewHandle<'static, T>> where
F: FnOnce(&'static [u8]) -> Result<T>,
[src]
F: FnOnce(&'static [u8]) -> Result<T>,
Constructs a ByteViewHandle
from a vector of bytes
fn from_reader<F, R>(reader: R, f: F) -> Result<ByteViewHandle<'static, T>> where
F: FnOnce(&'static [u8]) -> Result<T>,
R: Read,
[src]
F: FnOnce(&'static [u8]) -> Result<T>,
R: Read,
Constructs a ByteViewHandle
from a file path
fn from_path<F, P>(path: P, f: F) -> Result<ByteViewHandle<'static, T>> where
F: FnOnce(&'static [u8]) -> Result<T>,
P: AsRef<Path>,
[src]
F: FnOnce(&'static [u8]) -> Result<T>,
P: AsRef<Path>,
Constructs a ByteViewHandle
from a file path
fn get_bytes<'b>(this: &'b ByteViewHandle<'bytes, T>) -> &'b [u8]
[src]
Returns the underlying storage (byte slice)
Trait Implementations
impl<'bytes, T> Deref for ByteViewHandle<'bytes, T>
[src]
type Target = T
The resulting type after dereferencing.
fn deref(&self) -> &T
[src]
Dereferences the value.