pub struct Declared {
pub wow64_redirection: Option<Wow64Redirection>,
pub memory_priority: Option<MemoryPriority>,
pub background_mode: Option<BackgroundMode>,
}Expand description
The declared aspects a caller wants installed.
Every field is optional, and None means leave the running thread’s own
value alone. That is not the same as declaring a default: a declared
default would overwrite whatever the thread had.
Fields§
§wow64_redirection: Option<Wow64Redirection>WOW64 filesystem redirection.
memory_priority: Option<MemoryPriority>Thread memory priority.
background_mode: Option<BackgroundMode>Background processing mode, which moves CPU, I/O and memory priority together.
Implementations§
Source§impl Declared
impl Declared
Sourcepub const fn with_wow64_redirection(self, value: Wow64Redirection) -> Self
pub const fn with_wow64_redirection(self, value: Wow64Redirection) -> Self
Declare WOW64 filesystem redirection.
Sourcepub const fn with_memory_priority(self, value: MemoryPriority) -> Self
pub const fn with_memory_priority(self, value: MemoryPriority) -> Self
Declare a memory priority.
Sourcepub const fn with_background_mode(self, value: BackgroundMode) -> Self
pub const fn with_background_mode(self, value: BackgroundMode) -> Self
Declare a background processing mode.
Sourcepub fn install(&self) -> Result<DeclaredGuard, DeclaredError>
pub fn install(&self) -> Result<DeclaredGuard, DeclaredError>
Install these aspects on the calling thread until the guard is released.
Aspects are installed in a fixed order – background mode, then memory
priority, then WOW64 redirection – and
release undoes them in exact reverse, so the
thread passes back through each intermediate state rather than being
snapped to an assumed one.
§Errors
Returns DeclaredError if an aspect could not be installed. Every
aspect installed before the failing one is released first, so a failed
install leaves the thread as it found it.
Sourcepub fn with_applied<F, T>(&self, operation: F) -> Result<T, DeclaredError>where
F: FnOnce() -> T,
pub fn with_applied<F, T>(&self, operation: F) -> Result<T, DeclaredError>where
F: FnOnce() -> T,
Run operation with these aspects installed.
A convenience over install for callers that do not
need the operation’s value when restoration fails. A restore failure
discards the value, because there is no room in this signature for
both; a caller that must keep the value even then should use install
and DeclaredGuard::release directly, as the composite does.
§Errors
Returns DeclaredError if an aspect could not be installed, in which
case operation did not run; or if an aspect could not be restored
afterwards, in which case it did run and its value is discarded.