Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 31 variants UnexpectedEof { offset: usize, needed: usize, remaining: usize, }, Overflow(&'static str), OutOfRange { field: &'static str, value: u64, max: u64, }, FunctionIndexOutOfBounds { index: usize, count: usize, }, InvalidMagic(u32), UnsupportedVersion(u16), InvalidAddressOffsetSize { version: u16, size: u8, }, UnsupportedStringTableEncoding(u8), InvalidUuidSize(usize), V1BuildIdTooLong { size: usize, }, MissingSection(u32), DuplicateSection(u32), ZeroSizedSection { section_type: u32, }, SectionOutOfBounds { section_type: u32, offset: u64, size: u64, input_len: usize, }, InvalidOffset { offset: u64, input_len: usize, }, InvalidAlignment(usize), MalformedUleb { offset: usize, reason: &'static str, }, MalformedSleb { offset: usize, reason: &'static str, }, UnsupportedInfoType(u32), ZeroNameOffset, InvalidFormat(&'static str), InvalidModel(&'static str), Limit { context: &'static str, value: u64, limit: u64, }, Malformed { context: &'static str, detail: Box<str>, }, ElfParse { input: ElfInputKind, source: ParserError, }, Dwarf { source: ParserError, }, NotElf { input: ElfInputKind, }, CompanionMismatch { input: ElfInputKind, mismatch: CompanionMismatch, }, IoAtPath { operation: &'static str, path: PathBuf, source: Error, }, V1LimitExceeded { field: &'static str, value: u64, }, Io(Error),
}
Expand description

Errors produced while parsing, building, or writing GSYM data.

Variants fall into a few groups. Format errors report malformed input (InvalidMagic, UnexpectedEof, InvalidFormat and friends). Model errors report an invalid value handed to the builder or writer (InvalidModel, V1LimitExceeded). The rest cover I/O and, with the convert feature, ELF and DWARF diagnostics.

Matching on it needs a fallback arm.

use gsym::{Error, Gsym};

match Gsym::parse(&[0_u8; 48][..]) {
    Ok(_) => unreachable!("not a GSYM file"),
    // "Not GSYM at all" is often worth treating as a normal answer.
    Err(Error::InvalidMagic(_)) => {}
    Err(other) => return Err(other),
}

Display renders the full context, so {error} is enough for a log line. Wrapped causes are available through std::error::Error::source.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

UnexpectedEof

A read required bytes beyond the end of the input.

Fields

§offset: usize

Byte offset at which the read began.

§needed: usize

Number of bytes requested.

§remaining: usize

Number of bytes still available.

§

Overflow(&'static str)

Integer arithmetic overflowed while computing the named value.

§

OutOfRange

A numeric field exceeded its format-defined maximum.

Fields

§field: &'static str

Name of the invalid field.

§value: u64

Observed value.

§max: u64

Inclusive maximum accepted value.

§

FunctionIndexOutOfBounds

A requested address-table function index does not exist.

Fields

§index: usize

Requested zero-based index.

§count: usize

Number of indexed functions.

§

InvalidMagic(u32)

The input does not begin with the GSYM magic in either byte order.

§

UnsupportedVersion(u16)

The input uses a GSYM version this crate does not implement.

§

InvalidAddressOffsetSize

The address-offset width is illegal for the selected format version.

Fields

§version: u16

GSYM version whose width rules apply.

§size: u8

Encoded width in bytes.

§

UnsupportedStringTableEncoding(u8)

GSYM v2 requested an unsupported string-table encoding.

§

InvalidUuidSize(usize)

A GSYM v1 build identifier exceeds its fixed 20-byte field.

§

V1BuildIdTooLong

A requested GSYM v1 build identifier exceeds its fixed 20-byte field.

Fields

§size: usize

Requested build-identifier size.

§

MissingSection(u32)

A required GSYM v2 global-data section is absent.

§

DuplicateSection(u32)

A GSYM v2 global-data section type appears more than once.

§

ZeroSizedSection

A required GSYM v2 section has an empty byte range.

Fields

§section_type: u32

Numeric global-data section type.

§

SectionOutOfBounds

A GSYM v2 section extends outside the input.

Fields

§section_type: u32

Numeric global-data section type.

§offset: u64

Absolute file offset.

§size: u64

Declared section size.

§input_len: usize

Actual input length.

§

InvalidOffset

A referenced absolute file offset is outside the input.

Fields

§offset: u64

Referenced file offset.

§input_len: usize

Actual input length.

§

InvalidAlignment(usize)

A requested binary alignment is zero or unsupported.

§

MalformedUleb

An unsigned LEB128 value is truncated, overlong, or too wide.

Fields

§offset: usize

Offset of the first encoded byte.

§reason: &'static str

Static validation failure description.

§

MalformedSleb

A signed LEB128 value is truncated, overlong, or too wide.

Fields

§offset: usize

Offset of the first encoded byte.

§reason: &'static str

Static validation failure description.

§

UnsupportedInfoType(u32)

Full decoding encountered a FunctionInfo record type it cannot preserve.

§

ZeroNameOffset

A function or inline record references string-table offset zero as its name.

§

InvalidFormat(&'static str)

The input violates a GSYM format rule.

§

InvalidModel(&'static str)

A value handed to the builder or writer is not valid.

§

Limit

A count, size, or nesting depth exceeds an implementation or wire limit.

Fields

§context: &'static str

Value being bounded.

§value: u64

Observed value.

§limit: u64

Inclusive supported limit.

§

Malformed

Contextual malformed-data diagnostic requiring a dynamic explanation.

Fields

§context: &'static str

Data structure or input being parsed.

§detail: Box<str>

Detailed validation failure.

§

ElfParse

Available on crate feature convert only.

An ELF input could not be parsed.

Fields

§input: ElfInputKind

Role of the rejected ELF input.

§source: ParserError

Underlying parser error.

§

Dwarf

Available on crate feature convert only.

Gimli rejected malformed DWARF data.

Fields

§source: ParserError

Underlying DWARF parser error.

§

NotElf

Available on crate feature convert only.

A conversion input is a supported object format other than ELF.

Fields

§input: ElfInputKind

Role of the non-ELF input.

§

CompanionMismatch

Available on crate feature convert only.

A separate debug, symbol, or package file does not match the image.

Fields

§input: ElfInputKind

Role of the mismatching companion.

§mismatch: CompanionMismatch

Identity property that differs.

§

IoAtPath

A filesystem operation failed at a known path.

Fields

§operation: &'static str

Human-readable operation in progress.

§path: PathBuf

Filesystem path involved in the operation.

§source: Error

Underlying I/O error.

§

V1LimitExceeded

A 64-bit semantic model cannot be narrowed into GSYM v1 fields.

Fields

§field: &'static str

Field that cannot be represented.

§value: u64

Value requiring more than 32 bits.

§

Io(Error)

An unscoped I/O operation failed.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Available on crate feature convert only.
Source§

fn from(error: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more