[−][src]Struct gimli::read::EndianSlice
A &[u8] slice with endianity metadata.
This implements the Reader trait, which is used for all reading of DWARF sections.
Implementations
impl<'input, Endian> EndianSlice<'input, Endian> where
Endian: Endianity, [src][−]
Endian: Endianity,
pub fn new(slice: &'input [u8], endian: Endian) -> EndianSlice<'input, Endian>[src][−]
Construct a new EndianSlice with the given slice and endianity.
pub fn slice(&self) -> &'input [u8][src][−]
Return a reference to the raw slice.
pub fn split_at(
&self,
idx: usize
) -> (EndianSlice<'input, Endian>, EndianSlice<'input, Endian>)[src][−]
&self,
idx: usize
) -> (EndianSlice<'input, Endian>, EndianSlice<'input, Endian>)
Split the slice in two at the given index, resulting in the tuple where the first item has range [0, idx), and the second has range [idx, len). Panics if the index is out of bounds.
pub fn find(&self, byte: u8) -> Option<usize>[src][−]
Find the first occurence of a byte in the slice, and return its index.
pub fn offset_from(&self, base: EndianSlice<'input, Endian>) -> usize[src][−]
Return the offset of the start of the slice relative to the start of the given slice.
pub fn to_string(&self) -> Result<&'input str>[src][−]
Converts the slice to a string using str::from_utf8.
Returns an error if the slice contains invalid characters.
pub fn to_string_lossy(&self) -> Cow<'input, str>[src][−]
Converts the slice to a string, including invalid characters,
using String::from_utf8_lossy.
impl<'input, Endian> EndianSlice<'input, Endian> where
Endian: Endianity, [src][−]
Endian: Endianity,
Range Methods
Unfortunately, std::ops::Index must return a reference, so we can't
implement Index<Range<usize>> to return a new EndianSlice the way we would
like to. Instead, we abandon fancy indexing operators and have these plain
old methods.
pub fn range(&self, idx: Range<usize>) -> EndianSlice<'input, Endian>[src][−]
Take the given start..end range of the underlying slice and return a
new EndianSlice.
use gimli::{EndianSlice, LittleEndian}; let slice = &[0x01, 0x02, 0x03, 0x04]; let endian_slice = EndianSlice::new(slice, LittleEndian); assert_eq!(endian_slice.range(1..3), EndianSlice::new(&slice[1..3], LittleEndian));
pub fn range_from(&self, idx: RangeFrom<usize>) -> EndianSlice<'input, Endian>[src][−]
Take the given start.. range of the underlying slice and return a new
EndianSlice.
use gimli::{EndianSlice, LittleEndian}; let slice = &[0x01, 0x02, 0x03, 0x04]; let endian_slice = EndianSlice::new(slice, LittleEndian); assert_eq!(endian_slice.range_from(2..), EndianSlice::new(&slice[2..], LittleEndian));
pub fn range_to(&self, idx: RangeTo<usize>) -> EndianSlice<'input, Endian>[src][−]
Take the given ..end range of the underlying slice and return a new
EndianSlice.
use gimli::{EndianSlice, LittleEndian}; let slice = &[0x01, 0x02, 0x03, 0x04]; let endian_slice = EndianSlice::new(slice, LittleEndian); assert_eq!(endian_slice.range_to(..3), EndianSlice::new(&slice[..3], LittleEndian));
Trait Implementations
impl<'input, Endian: Clone> Clone for EndianSlice<'input, Endian> where
Endian: Endianity, [src][+]
Endian: Endianity,
impl<'input, Endian: Copy> Copy for EndianSlice<'input, Endian> where
Endian: Endianity, [src]
Endian: Endianity,
impl<'input, Endian: Debug> Debug for EndianSlice<'input, Endian> where
Endian: Endianity, [src][+]
Endian: Endianity,
impl<'input, Endian: Default> Default for EndianSlice<'input, Endian> where
Endian: Endianity, [src][+]
Endian: Endianity,
impl<'input, Endian> Deref for EndianSlice<'input, Endian> where
Endian: Endianity, [src][+]
Endian: Endianity,
impl<'input, Endian: Eq> Eq for EndianSlice<'input, Endian> where
Endian: Endianity, [src]
Endian: Endianity,
impl<'input, Endian: Hash> Hash for EndianSlice<'input, Endian> where
Endian: Endianity, [src][+]
Endian: Endianity,
impl<'input, Endian> Index<RangeFrom<usize>> for EndianSlice<'input, Endian> where
Endian: Endianity, [src][+]
Endian: Endianity,
impl<'input, Endian> Index<usize> for EndianSlice<'input, Endian> where
Endian: Endianity, [src][+]
Endian: Endianity,
impl<'input, Endian> Into<&'input [u8]> for EndianSlice<'input, Endian> where
Endian: Endianity, [src][+]
Endian: Endianity,
impl<'input, Endian: PartialEq> PartialEq<EndianSlice<'input, Endian>> for EndianSlice<'input, Endian> where
Endian: Endianity, [src][+]
Endian: Endianity,
impl<'input, Endian> Reader for EndianSlice<'input, Endian> where
Endian: Endianity, [src][+]
Endian: Endianity,
impl<'input, Endian> StructuralEq for EndianSlice<'input, Endian> where
Endian: Endianity, [src]
Endian: Endianity,
impl<'input, Endian> StructuralPartialEq for EndianSlice<'input, Endian> where
Endian: Endianity, [src]
Endian: Endianity,
Auto Trait Implementations
impl<'input, Endian> Send for EndianSlice<'input, Endian> where
Endian: Send,
Endian: Send,
impl<'input, Endian> Sync for EndianSlice<'input, Endian> where
Endian: Sync,
Endian: Sync,
impl<'input, Endian> Unpin for EndianSlice<'input, Endian> where
Endian: Unpin,
Endian: Unpin,
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,
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,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src][+]
U: TryFrom<T>,