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> {
slice: &'input [u8],
endian: Endian,
}
Fields§
§slice: &'input [u8]
§endian: Endian
Implementations
Source§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.
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));
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
.
fn read_slice(&mut self, len: usize) -> Result<&'input [u8]>
Trait Implementations
Source§impl<'input, Endian> Clone for EndianSlice<'input, Endian>
impl<'input, Endian> Clone for EndianSlice<'input, Endian>
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: Endianity> Debug for EndianSlice<'input, Endian>
impl<'input, Endian: Endianity> Debug for EndianSlice<'input, Endian>
Source§impl<'input, Endian> Default for EndianSlice<'input, Endian>
impl<'input, Endian> Default for EndianSlice<'input, Endian>
Source§fn default() -> EndianSlice<'input, Endian>
fn default() -> EndianSlice<'input, Endian>
Source§impl<'input, Endian> Deref for EndianSlice<'input, Endian>where
Endian: Endianity,
impl<'input, Endian> Deref for EndianSlice<'input, Endian>where
Endian: Endianity,
Source§impl<'input, Endian> Hash for EndianSlice<'input, Endian>
impl<'input, Endian> Hash for EndianSlice<'input, Endian>
Source§impl<'input, Endian> PartialEq for EndianSlice<'input, Endian>
impl<'input, Endian> PartialEq for 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>
fn read_u8_array<A>(&mut self) -> Result<A>
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_size(&mut self) -> Result<u8>
fn read_address_size(&mut self) -> Result<u8>
Source§fn read_address(&mut self, address_size: u8) -> Result<u64>
fn read_address(&mut self, address_size: u8) -> Result<u64>
u64
.