[−][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,
fn clone(&self) -> EndianSlice<'input, Endian>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
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,
fn default() -> EndianSlice<'input, Endian>
[src]
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,
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'input, Endian> Index<RangeFrom<usize>> for EndianSlice<'input, Endian> where
Endian: Endianity,
[src]
Endian: Endianity,
type Output = [u8]
The returned type after indexing.
fn index(&self, idx: RangeFrom<usize>) -> &Self::Output
[src]
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,
fn eq(&self, other: &EndianSlice<'input, Endian>) -> bool
[src]
fn ne(&self, other: &EndianSlice<'input, Endian>) -> bool
[src]
impl<'input, Endian> Reader for EndianSlice<'input, Endian> where
Endian: Endianity,
[src]
Endian: Endianity,
type Endian = Endian
The endianity of bytes that are read.
type Offset = usize
The type used for offsets and lengths.
fn endian(&self) -> Endian
[src]
fn len(&self) -> usize
[src]
fn is_empty(&self) -> bool
[src]
fn empty(&mut self)
[src]
fn truncate(&mut self, len: usize) -> Result<()>
[src]
fn offset_from(&self, base: &Self) -> usize
[src]
fn offset_id(&self) -> ReaderOffsetId
[src]
fn lookup_offset_id(&self, id: ReaderOffsetId) -> Option<Self::Offset>
[src]
fn find(&self, byte: u8) -> Result<usize>
[src]
fn skip(&mut self, len: usize) -> Result<()>
[src]
fn split(&mut self, len: usize) -> Result<Self>
[src]
fn to_slice(&self) -> Result<Cow<'_, [u8]>>
[src]
fn to_string(&self) -> Result<Cow<'_, str>>
[src]
fn to_string_lossy(&self) -> Result<Cow<'_, str>>
[src]
fn read_slice(&mut self, buf: &mut [u8]) -> Result<()>
[src]
fn read_u8_array<A>(&mut self) -> Result<A> where
A: Sized + Default + AsMut<[u8]>,
[src]
A: Sized + Default + AsMut<[u8]>,
fn read_u8(&mut self) -> Result<u8>
[src]
fn read_i8(&mut self) -> Result<i8>
[src]
fn read_u16(&mut self) -> Result<u16>
[src]
fn read_i16(&mut self) -> Result<i16>
[src]
fn read_u32(&mut self) -> Result<u32>
[src]
fn read_i32(&mut self) -> Result<i32>
[src]
fn read_u64(&mut self) -> Result<u64>
[src]
fn read_i64(&mut self) -> Result<i64>
[src]
fn read_f32(&mut self) -> Result<f32>
[src]
fn read_f64(&mut self) -> Result<f64>
[src]
fn read_uint(&mut self, n: usize) -> Result<u64>
[src]
fn read_null_terminated_slice(&mut self) -> Result<Self>
[src]
fn read_uleb128(&mut self) -> Result<u64>
[src]
fn read_uleb128_u16(&mut self) -> Result<u16>
[src]
fn read_sleb128(&mut self) -> Result<i64>
[src]
fn read_initial_length(&mut self) -> Result<(Self::Offset, Format)>
[src]
fn read_address(&mut self, address_size: u8) -> Result<u64>
[src]
fn read_word(&mut self, format: Format) -> Result<Self::Offset>
[src]
fn read_length(&mut self, format: Format) -> Result<Self::Offset>
[src]
fn read_offset(&mut self, format: Format) -> Result<Self::Offset>
[src]
fn read_sized_offset(&mut self, size: u8) -> Result<Self::Offset>
[src]
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,
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>,