pub type EndianBuf<'input, Endian> = EndianSlice<'input, Endian>;
Expand description
EndianBuf
has been renamed to EndianSlice
. For ease of upgrading across
gimli
versions, we export this type alias.
Aliased Type§
struct EndianBuf<'input, Endian> { /* private fields */ }
Implementations
source§impl<'input, Endian> EndianSlice<'input, Endian>where
Endian: Endianity,
impl<'input, Endian> EndianSlice<'input, Endian>where Endian: Endianity,
sourcepub fn new(slice: &'input [u8], endian: Endian) -> EndianSlice<'input, Endian>
pub fn new(slice: &'input [u8], endian: Endian) -> EndianSlice<'input, Endian>
Construct a new EndianSlice
with the given slice and endianity.
sourcepub 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.
sourcepub fn find(&self, byte: u8) -> Option<usize>
pub fn find(&self, byte: u8) -> Option<usize>
Find the first occurrence of a byte in the slice, and return its index.
sourcepub fn offset_from(&self, base: EndianSlice<'input, Endian>) -> usize
pub fn offset_from(&self, base: EndianSlice<'input, Endian>) -> usize
Return the offset of the start of the slice relative to the start of the given slice.
sourcepub fn to_string(&self) -> Result<&'input str>
pub fn to_string(&self) -> Result<&'input str>
Converts the slice to a string using str::from_utf8
.
Returns an error if the slice contains invalid characters.
sourcepub fn to_string_lossy(&self) -> Cow<'input, str>
pub fn to_string_lossy(&self) -> Cow<'input, str>
Converts the slice to a string, including invalid characters,
using String::from_utf8_lossy
.
source§impl<'input, Endian> EndianSlice<'input, Endian>where
Endian: Endianity,
impl<'input, Endian> EndianSlice<'input, Endian>where 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.
sourcepub fn range(&self, idx: Range<usize>) -> EndianSlice<'input, Endian>
pub fn range(&self, idx: Range<usize>) -> EndianSlice<'input, Endian>
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));
sourcepub fn range_from(&self, idx: RangeFrom<usize>) -> EndianSlice<'input, Endian>
pub fn range_from(&self, idx: RangeFrom<usize>) -> EndianSlice<'input, Endian>
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));
sourcepub fn range_to(&self, idx: RangeTo<usize>) -> EndianSlice<'input, Endian>
pub fn range_to(&self, idx: RangeTo<usize>) -> EndianSlice<'input, Endian>
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> StructuralEq for EndianSlice<'input, Endian>where Endian: Endianity,
source§impl<'input, Endian> Clone for EndianSlice<'input, Endian>where
Endian: Endianity + Clone,
impl<'input, Endian> Clone for EndianSlice<'input, Endian>where Endian: Endianity + Clone,
source§fn clone(&self) -> EndianSlice<'input, Endian>
fn clone(&self) -> EndianSlice<'input, Endian>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§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,
source§impl<'input, Endian> PartialEq for EndianSlice<'input, Endian>where
Endian: Endianity + PartialEq,
impl<'input, Endian> PartialEq for EndianSlice<'input, Endian>where Endian: Endianity + PartialEq,
source§fn eq(&self, other: &EndianSlice<'input, Endian>) -> bool
fn eq(&self, other: &EndianSlice<'input, Endian>) -> bool
self
and other
values to be equal, and is used
by ==
.impl<'input, Endian> Eq for EndianSlice<'input, Endian>where Endian: Endianity + Eq,
source§impl<'input, Endian> Default for EndianSlice<'input, Endian>where
Endian: Endianity + Default,
impl<'input, Endian> Default for EndianSlice<'input, Endian>where Endian: Endianity + Default,
source§fn default() -> EndianSlice<'input, Endian>
fn default() -> EndianSlice<'input, Endian>
source§impl<'input, Endian> Reader for EndianSlice<'input, Endian>where
Endian: Endianity,
impl<'input, Endian> Reader for EndianSlice<'input, Endian>where Endian: Endianity,
source§fn truncate(&mut self, len: usize) -> Result<()>
fn truncate(&mut self, len: usize) -> Result<()>
source§fn offset_from(&self, base: &Self) -> usize
fn offset_from(&self, base: &Self) -> usize
source§fn offset_id(&self) -> ReaderOffsetId
fn offset_id(&self) -> ReaderOffsetId
source§fn lookup_offset_id(&self, id: ReaderOffsetId) -> Option<Self::Offset>
fn lookup_offset_id(&self, id: ReaderOffsetId) -> Option<Self::Offset>
id
if
it is associated with this reader.source§fn find(&self, byte: u8) -> Result<usize>
fn find(&self, byte: u8) -> Result<usize>
source§fn to_slice(&self) -> Result<Cow<'_, [u8]>>
fn to_slice(&self) -> Result<Cow<'_, [u8]>>
source§fn to_string(&self) -> Result<Cow<'_, str>>
fn to_string(&self) -> Result<Cow<'_, str>>
source§fn to_string_lossy(&self) -> Result<Cow<'_, str>>
fn to_string_lossy(&self) -> Result<Cow<'_, str>>
source§fn read_u8_array<A>(&mut self) -> Result<A>where
A: Sized + Default + AsMut<[u8]>,
fn read_u8_array<A>(&mut self) -> Result<A>where A: Sized + Default + AsMut<[u8]>,
source§fn read_uint(&mut self, n: usize) -> Result<u64>
fn read_uint(&mut self, n: usize) -> Result<u64>
source§fn read_null_terminated_slice(&mut self) -> Result<Self>
fn read_null_terminated_slice(&mut self) -> Result<Self>
source§fn skip_leb128(&mut self) -> Result<()>
fn skip_leb128(&mut self) -> Result<()>
source§fn read_uleb128(&mut self) -> Result<u64>
fn read_uleb128(&mut self) -> Result<u64>
source§fn read_uleb128_u32(&mut self) -> Result<u32>
fn read_uleb128_u32(&mut self) -> Result<u32>
source§fn read_uleb128_u16(&mut self) -> Result<u16>
fn read_uleb128_u16(&mut self) -> Result<u16>
source§fn read_sleb128(&mut self) -> Result<i64>
fn read_sleb128(&mut self) -> Result<i64>
source§fn read_initial_length(&mut self) -> Result<(Self::Offset, Format)>
fn read_initial_length(&mut self) -> Result<(Self::Offset, Format)>
source§fn read_address(&mut self, address_size: u8) -> Result<u64>
fn read_address(&mut self, address_size: u8) -> Result<u64>
u64
.