#[non_exhaustive]pub enum ModuleInfoError {
NotAvailable(String),
NullPointer,
Utf8Error(Utf8Error),
MalformedJson(String),
MetadataTooLarge(String),
IoError(Error),
Other(Box<dyn Error + Send + Sync>),
}Expand description
Errors returned from module_info APIs.
#[non_exhaustive]: new variants may land in minor releases. Any match
on this enum from outside the crate needs a wildcard arm or it will
fail to compile when a variant is added.
§Example
use module_info::{ModuleInfoError, ModuleInfoResult};
// A function that might return a ModuleInfoError
fn get_module_name() -> ModuleInfoResult<String> {
Err(ModuleInfoError::NotAvailable("example".to_string()))
}
match get_module_name() {
Ok(name) => println!("Module name: {name}"),
Err(ModuleInfoError::NotAvailable(msg)) => eprintln!("not available: {msg}"),
Err(ModuleInfoError::NullPointer) => eprintln!("null pointer"),
Err(ModuleInfoError::MalformedJson(msg)) => eprintln!("malformed JSON: {msg}"),
Err(e) => eprintln!("other error: {e}"),
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
NotAvailable(String)
Module info is unavailable: either the embed-module-info feature is
off or the target is not Linux. The contained string carries context.
NullPointer
A null pointer was passed to extract_module_info. Typically means
the linker script did not run or the .note.package section was
stripped from the binary.
Utf8Error(Utf8Error)
The embedded bytes were not valid UTF-8.
MalformedJson(String)
The embedded JSON could not be parsed, a required field is missing
or empty, or moduleVersion is not four u16-sized parts. The
contained string identifies the specific failure.
MetadataTooLarge(String)
The serialized metadata JSON exceeded MAX_JSON_SIZE (1 KiB) at
build time. The contained string reports the actual vs. allowed size.
IoError(Error)
I/O failure while reading Cargo.toml or writing the generated
linker script and JSON dump from build.rs.
Other(Box<dyn Error + Send + Sync>)
Catch-all for errors that do not fit the variants above. Holds the
originating error for source() chaining.
Trait Implementations§
Source§impl Debug for ModuleInfoError
impl Debug for ModuleInfoError
Source§impl Display for ModuleInfoError
impl Display for ModuleInfoError
Source§impl Error for ModuleInfoError
impl Error for ModuleInfoError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()