Skip to main content

try_page_size

Function try_page_size 

Source
pub fn try_page_size() -> Result<usize, VmemError>
Expand description

Fallible page_size: the same cached one-time OS page-size query, with a channel for the one thing page_size cannot report — the query itself having failed.

page_size is deliberately infallible: it returns the conservative MIN_PAGE floor when the one-time OS query produced an unusable answer, and the crate fails every page-granular state operation closed from then on (see page_size’s own “If the one-time OS query fails” paragraph). This twin is the upfront detector: a caller that wants to choose a strategy at startup — rather than discover the degraded state through try_decommit errors — asks here once.

§Errors

VmemError::os_refusal_unknown_code if the OS page-size query failed (not observed on any supported platform; see page_size’s rustdoc for why). The error is an OS-side no-code failure, NOT VmemError::invalid_argument — the caller did nothing wrong.

On success, the returned value is identical to page_size()’s: a power of two >= MIN_PAGE, stable for the process lifetime.