[−][src]Struct symbolic_common::ByteView
A smart pointer for byte data.
This type can be used to uniformly access bytes that were created either from mmapping in a
path, a vector or a borrowed slice. A byteview derefs into a &[u8]
and is used in symbolic in
most situations where binary files are worked with.
A ByteView
can be constructed from borrowed slices, vectors or mmaped from the file system
directly.
Example
let bv = ByteView::from_slice(b"1234"); assert_eq!(&*bv, b"1234");
Methods
impl<'a> ByteView<'a>
[src]
pub fn from_cow(cow: Cow<'a, [u8]>) -> Self
[src]
Constructs a ByteView
from a Cow
.
pub fn from_slice(buffer: &'a [u8]) -> Self
[src]
Constructs a ByteView
from a byte slice.
pub fn from_vec(buffer: Vec<u8>) -> Self
[src]
Constructs a ByteView
from a vector of bytes.
pub fn map_file(file: File) -> Result<Self, Error>
[src]
Constructs a ByteView
from an open file handle by memory mapping the file.
pub fn read<R: Read>(reader: R) -> Result<Self, Error>
[src]
Constructs a ByteView
from any std::io::Reader
.
This currently consumes the entire reader and stores its data in an internal buffer. Prefer
ByteView::open
when reading from the file system or ByteView::from_slice
/
ByteView::from_vec
for in-memory operations. This behavior might change in the future.
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, Error>
[src]
Constructs a ByteView
from a file path by memory mapping the file.
pub fn as_slice(&self) -> &[u8]
[src]
Returns a slice of the underlying data.
Trait Implementations
impl<'_> AsRef<[u8]> for ByteView<'_>
[src]
impl<'a> Clone for ByteView<'a>
[src]
fn clone(&self) -> ByteView<'a>
[src]
default fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'_> Deref for ByteView<'_>
[src]
impl<'a> Debug for ByteView<'a>
[src]
impl<'_> StableDeref for ByteView<'_>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom 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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,