Struct symbolic_common::byteview::ByteViewHandle
source · pub struct ByteViewHandle<'bytes, T> { /* private fields */ }Expand description
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.
Implementations§
source§impl<'bytes, T> ByteViewHandle<'bytes, T>
impl<'bytes, T> ByteViewHandle<'bytes, T>
sourcepub fn from_byteview<F, E>(
view: ByteView<'bytes>,
f: F
) -> Result<ByteViewHandle<'bytes, T>, E>where
F: FnOnce(&'bytes [u8]) -> Result<T, E>,
pub fn from_byteview<F, E>(
view: ByteView<'bytes>,
f: F
) -> Result<ByteViewHandle<'bytes, T>, E>where
F: FnOnce(&'bytes [u8]) -> Result<T, E>,
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.
sourcepub fn from_slice<F, E>(
buffer: &'bytes [u8],
f: F
) -> Result<ByteViewHandle<'bytes, T>, E>where
F: FnOnce(&'bytes [u8]) -> Result<T, E>,
pub fn from_slice<F, E>(
buffer: &'bytes [u8],
f: F
) -> Result<ByteViewHandle<'bytes, T>, E>where
F: FnOnce(&'bytes [u8]) -> Result<T, E>,
Constructs a ByteViewHandle from a byte slice.
sourcepub fn from_vec<F, E>(
vec: Vec<u8>,
f: F
) -> Result<ByteViewHandle<'static, T>, E>where
F: FnOnce(&'static [u8]) -> Result<T, E>,
pub fn from_vec<F, E>(
vec: Vec<u8>,
f: F
) -> Result<ByteViewHandle<'static, T>, E>where
F: FnOnce(&'static [u8]) -> Result<T, E>,
Constructs a ByteViewHandle from a vector of bytes.
sourcepub fn from_reader<F, R, E>(
reader: R,
f: F
) -> Result<ByteViewHandle<'static, T>, E>where
F: FnOnce(&'static [u8]) -> Result<T, E>,
E: From<Error>,
R: Read,
pub fn from_reader<F, R, E>(
reader: R,
f: F
) -> Result<ByteViewHandle<'static, T>, E>where
F: FnOnce(&'static [u8]) -> Result<T, E>,
E: From<Error>,
R: Read,
Constructs a ByteViewHandle from a file path.
sourcepub fn from_path<F, P, E>(path: P, f: F) -> Result<ByteViewHandle<'static, T>, E>where
F: FnOnce(&'static [u8]) -> Result<T, E>,
E: From<Error>,
P: AsRef<Path>,
pub fn from_path<F, P, E>(path: P, f: F) -> Result<ByteViewHandle<'static, T>, E>where
F: FnOnce(&'static [u8]) -> Result<T, E>,
E: From<Error>,
P: AsRef<Path>,
Constructs a ByteViewHandle from a file path.
sourcepub fn get_bytes<'b>(this: &'b ByteViewHandle<'bytes, T>) -> &'b [u8] ⓘ
pub fn get_bytes<'b>(this: &'b ByteViewHandle<'bytes, T>) -> &'b [u8] ⓘ
Returns the underlying storage (byte slice).