pub struct ReadError(/* private fields */);Expand description
An error returned while reading memory from a target process.
ReadError is intentionally a small public wrapper around private strategy
errors. Its Display implementation describes the high-level failure. Its
core::error::Error::source implementation returns a lower-level source
when there is exactly one failed strategy, including failures from forced
strategies and failures from a strategy selected by an automatic reader.
Short successful reads are not represented by ReadError; they are returned
from crate::ProcessReader::read_at as Ok(n) where n is smaller than
the requested buffer length.
When crate::ProcessReader::new tries every strategy and all of them fail,
there is no single source error. In that case
core::error::Error::source returns None, and callers can inspect each
branch with
ReadError::virtual_mem_error, ReadError::file_error, and
ReadError::ptrace_error.
If the serde feature is enabled, this type implements Serialize and
Deserialize.
Implementations§
Source§impl ReadError
impl ReadError
Sourcepub fn virtual_mem_error(&self) -> Option<&(dyn StdError + 'static)>
pub fn virtual_mem_error(&self) -> Option<&(dyn StdError + 'static)>
Returns the error from the process_vm_readv(2) strategy, if present.
This returns Some when a reader forced to or cached on
crate::ProcessReader::for_virtual_mem fails, and when automatic
strategy selection fails after attempting process_vm_readv.
It returns None when the error does not contain a process_vm_readv
failure.
Sourcepub fn file_error(&self) -> Option<&(dyn StdError + 'static)>
pub fn file_error(&self) -> Option<&(dyn StdError + 'static)>
Returns the error from the /proc/<pid>/mem strategy, if present.
This returns Some when a reader forced to or cached on
crate::ProcessReader::for_file fails, and when automatic strategy
selection fails after attempting to use /proc/<pid>/mem.
It returns None when the error does not contain a /proc/<pid>/mem
failure.
Sourcepub fn ptrace_error(&self) -> Option<&(dyn StdError + 'static)>
pub fn ptrace_error(&self) -> Option<&(dyn StdError + 'static)>
Returns the error from the ptrace(PTRACE_PEEKDATA) strategy, if present.
This returns Some when a reader forced to or cached on
crate::ProcessReader::for_ptrace fails, and when automatic strategy
selection fails after attempting ptrace(PTRACE_PEEKDATA).
It returns None when the error does not contain a ptrace failure.
Trait Implementations§
Source§impl Error for ReadError
impl Error for ReadError
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()