Struct gimli::read::EndianSlice [−][src]
pub struct EndianSlice<'input, Endian> where
Endian: Endianity, { /* fields omitted */ }
Expand description
A &[u8]
slice with endianity metadata.
This implements the Reader
trait, which is used for all reading of DWARF sections.
Implementations
Construct a new EndianSlice
with the given slice and endianity.
pub fn split_at(
&self,
idx: usize
) -> (EndianSlice<'input, Endian>, EndianSlice<'input, Endian>)
pub fn split_at(
&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.
Find the first occurence of a byte in the slice, and return its index.
Return the offset of the start of the slice relative to the start of the given slice.
Converts the slice to a string using str::from_utf8
.
Returns an error if the slice contains invalid characters.
Converts the slice to a string, including invalid characters,
using String::from_utf8_lossy
.
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.
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));
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));
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
Returns the “default value” for a type. Read more
impl<'input, Endian> Index<RangeFrom<usize>> for EndianSlice<'input, Endian> where
Endian: Endianity,
impl<'input, Endian> Index<RangeFrom<usize>> for EndianSlice<'input, Endian> where
Endian: Endianity,
impl<'input, Endian> Into<&'input [u8]> for EndianSlice<'input, Endian> where
Endian: Endianity,
impl<'input, Endian> Into<&'input [u8]> for EndianSlice<'input, Endian> where
Endian: Endianity,
impl<'input, Endian: PartialEq> PartialEq<EndianSlice<'input, Endian>> for EndianSlice<'input, Endian> where
Endian: Endianity,
impl<'input, Endian: PartialEq> PartialEq<EndianSlice<'input, Endian>> for EndianSlice<'input, Endian> where
Endian: Endianity,
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
type Endian = Endian
type Endian = Endian
The endianity of bytes that are read.
type Offset = usize
type Offset = usize
The type used for offsets and lengths.
Set the number of bytes remaining to the specified length.
Return the offset of this reader’s data relative to the start of the given base reader’s data. Read more
Return an identifier for the current reader offset.
Return the offset corresponding to the given id
if
it is associated with this reader. Read more
Find the index of the first occurence of the given byte. The offset of the reader is not changed. Read more
Return all remaining data as a clone-on-write slice. Read more
Convert all remaining data to a clone-on-write string. Read more
Convert all remaining data to a clone-on-write string, including invalid characters. Read more
Read exactly buf.len()
bytes into buf
.
Read a u8 array.
Read an unsigned n-bytes integer u64. Read more
Read a null-terminated slice, and return it (excluding the null).
Read an unsigned LEB128 encoded integer.
Read an unsigned LEB128 encoded u32.
Read an unsigned LEB128 encoded u16.
Read a signed LEB128 encoded integer.
Read an initial length field. Read more
Read an address-sized integer, and return it as a u64
.
Parse a word-sized integer according to the DWARF format. Read more
Parse a word-sized section length according to the DWARF format.
Parse a word-sized section offset according to the DWARF format.
Parse a section offset of the given size. Read more
impl<'input, Endian> StructuralPartialEq for EndianSlice<'input, Endian> where
Endian: Endianity,
Auto Trait Implementations
impl<'input, Endian> RefUnwindSafe for EndianSlice<'input, Endian> where
Endian: RefUnwindSafe,
impl<'input, Endian> Send for EndianSlice<'input, Endian> where
Endian: Send,
impl<'input, Endian> Sync for EndianSlice<'input, Endian> where
Endian: Sync,
impl<'input, Endian> Unpin for EndianSlice<'input, Endian> where
Endian: Unpin,
impl<'input, Endian> UnwindSafe for EndianSlice<'input, Endian> where
Endian: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more