[−][src]Struct object::pod::Bytes
A newtype for byte slices.
It has these important features:
- no methods that can panic, such as
Index
- convenience methods for
Pod
types - a useful
Debug
implementation
Implementations
impl<'data> Bytes<'data>
[src]
pub fn len(&self) -> usize
[src]
Return the length of the byte slice.
pub fn is_empty(&self) -> bool
[src]
Return true if the byte slice is empty.
pub fn skip(&mut self, offset: usize) -> Result<(), ()>
[src]
Skip over the given number of bytes at the start of the byte slice.
Modifies the byte slice to start after the bytes.
Returns an error if there are too few bytes.
pub fn read_bytes(&mut self, count: usize) -> Result<Bytes<'data>, ()>
[src]
Return a reference to the given number of bytes at the start of the byte slice.
Modifies the byte slice to start after the bytes.
Returns an error if there are too few bytes.
pub fn read_bytes_at(
self,
offset: usize,
count: usize
) -> Result<Bytes<'data>, ()>
[src]
self,
offset: usize,
count: usize
) -> Result<Bytes<'data>, ()>
Return a reference to the given number of bytes at the given offset of the byte slice.
Returns an error if the offset is invalid or there are too few bytes.
pub fn read<T: Pod>(&mut self) -> Result<&'data T, ()>
[src]
Return a reference to a Pod
struct at the start of the byte slice.
Modifies the byte slice to start after the bytes.
Returns an error if there are too few bytes or the slice is incorrectly aligned.
pub fn read_at<T: Pod>(self, offset: usize) -> Result<&'data T, ()>
[src]
Return a reference to a Pod
struct at the given offset of the byte slice.
Returns an error if there are too few bytes or the offset is incorrectly aligned.
pub fn read_slice<T: Pod>(&mut self, count: usize) -> Result<&'data [T], ()>
[src]
Return a reference to a slice of Pod
structs at the start of the byte slice.
Modifies the byte slice to start after the bytes.
Returns an error if there are too few bytes or the offset is incorrectly aligned.
pub fn read_slice_at<T: Pod>(
self,
offset: usize,
count: usize
) -> Result<&'data [T], ()>
[src]
self,
offset: usize,
count: usize
) -> Result<&'data [T], ()>
Return a reference to a slice of Pod
structs at the given offset of the byte slice.
Returns an error if there are too few bytes or the offset is incorrectly aligned.
pub fn read_string(&mut self) -> Result<&'data [u8], ()>
[src]
Read a null terminated string.
Does not assume any encoding. Reads past the null byte, but doesn't return it.
pub fn read_string_at(self, offset: usize) -> Result<&'data [u8], ()>
[src]
Read a null terminated string at an offset.
Does not assume any encoding. Does not return the null byte.
Trait Implementations
impl<'data> Clone for Bytes<'data>
[src]
fn clone(&self) -> Bytes<'data>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'data> Copy for Bytes<'data>
[src]
impl<'data> Debug for Bytes<'data>
[src]
impl<'data> Default for Bytes<'data>
[src]
impl<'data> Eq for Bytes<'data>
[src]
impl<'data> PartialEq<Bytes<'data>> for Bytes<'data>
[src]
impl<'data> StructuralEq for Bytes<'data>
[src]
impl<'data> StructuralPartialEq for Bytes<'data>
[src]
Auto Trait Implementations
impl<'data> Send for Bytes<'data>
impl<'data> Sync for Bytes<'data>
impl<'data> Unpin for Bytes<'data>
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,