#[non_exhaustive]pub enum PagerError {
ZeroSize,
SizeOverflow,
Map(i32),
Protect(i32),
NotWritable,
OutOfBounds {
offset: usize,
len: usize,
region_len: usize,
},
}Expand description
The reason a Region operation failed.
The variants separate the three places things go wrong: a request that does not describe
a valid region (ZeroSize, SizeOverflow), the
operating system refusing a call (Map, Protect), and a
write that does not fit the region as it currently stands (NotWritable,
OutOfBounds). The OS-level variants carry the raw error code —
errno on Unix, GetLastError on Windows — so the underlying cause is not lost.
The set is #[non_exhaustive]: future platforms or features may add variants, so a
match on this type must include a wildcard arm.
§Examples
use pager_lang::{PagerError, Region};
// A region must be at least one page; zero bytes is rejected up front.
assert!(matches!(Region::new(0), Err(PagerError::ZeroSize)));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ZeroSize
A region of zero bytes was requested. A region must span at least one page; ask for the number of bytes you need and the request is rounded up to whole pages.
SizeOverflow
Rounding the request up to whole pages, or adding the guard pages, overflowed
usize. The requested size is too large to represent, let alone map.
Map(i32)
The operating system refused to map the region. The wrapped value is the OS error
code (errno / GetLastError); the usual cause is exhausted address space or
memory.
Protect(i32)
The operating system refused to change the region’s protection. The wrapped value is
the OS error code. A frequent cause is a platform that forbids writable-and-executable
pages, which rejects Protection::ReadWriteExecute.
NotWritable
A write was attempted on a region whose current protection does not permit writing.
Flip it to Protection::ReadWrite with
Region::protect first.
OutOfBounds
A write would have fallen outside the region: offset + len exceeded the region’s
length. The fields report what was attempted against the region that exists.
Trait Implementations§
Source§impl Clone for PagerError
impl Clone for PagerError
Source§fn clone(&self) -> PagerError
fn clone(&self) -> PagerError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PagerError
impl Debug for PagerError
Source§impl<'de> Deserialize<'de> for PagerError
impl<'de> Deserialize<'de> for PagerError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for PagerError
impl Display for PagerError
impl Eq for PagerError
Source§impl Error for PagerError
impl Error for PagerError
1.30.0 · 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()
Source§impl PartialEq for PagerError
impl PartialEq for PagerError
Source§fn eq(&self, other: &PagerError) -> bool
fn eq(&self, other: &PagerError) -> bool
self and other values to be equal, and is used by ==.