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.

Return a reference to the raw slice.

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 a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The resulting type after dereferencing.

Dereferences the value.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The endianity of bytes that are read.

The type used for offsets and lengths.

Return the endianity of bytes that are read.

Return the number of bytes remaining.

Return true if the number of bytes remaining is zero.

Set the number of bytes remaining to zero.

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

Discard the specified number of bytes.

Split a reader in two. 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 a u8.

Read an i8.

Read a u16.

Read an i16.

Read a u32.

Read an i32.

Read a u64.

Read an i64.

Read a f32.

Read a f64.

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.