Skip to main content

ReadError

Struct ReadError 

Source
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

Source

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.

Source

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.

Source

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 Debug for ReadError

Source§

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

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

impl Display for ReadError

Source§

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

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

impl Error for ReadError

Source§

fn source(&self) -> Option<&(dyn StdError + '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

Auto Trait Implementations§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.