Trait gimli::Reader
[−]
[src]
pub trait Reader: Debug + Clone { type Endian: Endianity; type Offset: ReaderOffset; fn endian(&self) -> Self::Endian; fn len(&self) -> Self::Offset; fn is_empty(&self) -> bool; fn empty(&mut self); fn truncate(&mut self, len: Self::Offset) -> Result<()>; fn offset_from(&self, base: &Self) -> Self::Offset; fn find(&self, byte: u8) -> Result<Self::Offset>; fn skip(&mut self, len: Self::Offset) -> Result<()>; fn split(&mut self, len: Self::Offset) -> Result<Self>; fn to_slice(&self) -> Result<Cow<[u8]>>; fn to_string(&self) -> Result<Cow<str>>; fn to_string_lossy(&self) -> Result<Cow<str>>; fn read_u8_array<A>(&mut self) -> Result<A>
where
A: Sized + Default + AsMut<[u8]>; fn read_u8(&mut self) -> Result<u8>; fn read_i8(&mut self) -> Result<i8>; fn read_u16(&mut self) -> Result<u16>; fn read_i16(&mut self) -> Result<i16>; fn read_u32(&mut self) -> Result<u32>; fn read_i32(&mut self) -> Result<i32>; fn read_u64(&mut self) -> Result<u64>; fn read_i64(&mut self) -> Result<i64>; fn read_null_terminated_slice(&mut self) -> Result<Self> { ... } fn read_uleb128(&mut self) -> Result<u64> { ... } fn read_sleb128(&mut self) -> Result<i64> { ... } fn read_address(&mut self, address_size: u8) -> Result<u64> { ... } fn read_word(&mut self, format: Format) -> Result<u64> { ... } fn read_offset(&mut self, format: Format) -> Result<Self::Offset> { ... } }
A trait for reading the data from a DWARF section.
All read operations advance the section offset of the reader unless specified otherwise.
Associated Types
type Endian: Endianity
The endianity of bytes that are read.
type Offset: ReaderOffset
The type used for offsets and lengths.
Required Methods
fn endian(&self) -> Self::Endian
Return the endianity of bytes that are read.
fn len(&self) -> Self::Offset
Return the number of bytes remaining.
fn is_empty(&self) -> bool
Return true if the number of bytes remaining is zero.
fn empty(&mut self)
Set the number of bytes remaining to zero.
fn truncate(&mut self, len: Self::Offset) -> Result<()>
Set the number of bytes remaining to the specified length.
fn offset_from(&self, base: &Self) -> Self::Offset
Return the offset of this reader's data relative to the start of the given base reader's data.
May panic if this reader's data is not contained within the given base reader's data.
fn find(&self, byte: u8) -> Result<Self::Offset>
Find the index of the first occurence of the given byte. The offset of the reader is not changed.
fn skip(&mut self, len: Self::Offset) -> Result<()>
Discard the specified number of bytes.
fn split(&mut self, len: Self::Offset) -> Result<Self>
Split a reader in two.
A new reader is returned that can be used to read the next
len
bytes, and self
is advanced so that it reads the remainder.
fn to_slice(&self) -> Result<Cow<[u8]>>
Return all remaining data as a clone-on-write slice.
The slice will be borrowed where possible, but some readers may always return an owned vector.
Does not advance the reader.
fn to_string(&self) -> Result<Cow<str>>
Convert all remaining data to a clone-on-write string.
The string will be borrowed where possible, but some readers may always return an owned string.
Does not advance the reader.
Returns an error if the data contains invalid characters.
fn to_string_lossy(&self) -> Result<Cow<str>>
Convert all remaining data to a clone-on-write string, including invalid characters.
The string will be borrowed where possible, but some readers may always return an owned string.
Does not advance the reader.
fn read_u8_array<A>(&mut self) -> Result<A> where
A: Sized + Default + AsMut<[u8]>,
A: Sized + Default + AsMut<[u8]>,
Read a u8 array.
fn read_u8(&mut self) -> Result<u8>
Read a u8.
fn read_i8(&mut self) -> Result<i8>
Read an i8.
fn read_u16(&mut self) -> Result<u16>
Read a u16.
fn read_i16(&mut self) -> Result<i16>
Read an i16.
fn read_u32(&mut self) -> Result<u32>
Read a u32.
fn read_i32(&mut self) -> Result<i32>
Read an i32.
fn read_u64(&mut self) -> Result<u64>
Read a u64.
fn read_i64(&mut self) -> Result<i64>
Read an i64.
Provided Methods
fn read_null_terminated_slice(&mut self) -> Result<Self>
Read a null-terminated slice, and return it (excluding the null).
fn read_uleb128(&mut self) -> Result<u64>
Read an unsigned LEB128 encoded integer.
fn read_sleb128(&mut self) -> Result<i64>
Read a signed LEB128 encoded integer.
fn read_address(&mut self, address_size: u8) -> Result<u64>
Read an address-sized integer, and return it as a u64
.
fn read_word(&mut self, format: Format) -> Result<u64>
Parse a word-sized integer according to the DWARF format, and return it as a u64
.
fn read_offset(&mut self, format: Format) -> Result<Self::Offset>
Parse a word-sized integer according to the DWARF format, and return it as an offset.