[][src]Struct gimli::read::EndianSlice

pub struct EndianSlice<'input, Endian> where
    Endian: Endianity
{ /* fields omitted */ }

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]

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]

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]

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]

impl<'input, Endian: Copy> Copy for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

impl<'input, Endian: Debug> Debug for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

impl<'input, Endian: Default> Default for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

impl<'input, Endian> Deref for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

type Target = [u8]

The resulting type after dereferencing.

impl<'input, Endian: Eq> Eq for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

impl<'input, Endian: Hash> Hash for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

impl<'input, Endian> Index<RangeFrom<usize>> for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

type Output = [u8]

The returned type after indexing.

impl<'input, Endian> Index<usize> for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

type Output = u8

The returned type after indexing.

impl<'input, Endian> Into<&'input [u8]> for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

impl<'input, Endian: PartialEq> PartialEq<EndianSlice<'input, Endian>> for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

impl<'input, Endian> Reader for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

type Endian = Endian

The endianity of bytes that are read.

type Offset = usize

The type used for offsets and lengths.

impl<'input, Endian> StructuralEq for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

impl<'input, Endian> StructuralPartialEq for EndianSlice<'input, Endian> where
    Endian: Endianity
[src]

Auto Trait Implementations

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.