Skip to main content

Declared

Struct Declared 

Source
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

Source

pub const fn none() -> Self

Declare nothing, leaving every aspect of the running thread alone.

Source

pub const fn is_empty(&self) -> bool

Whether anything at all would be installed.

Source

pub const fn with_wow64_redirection(self, value: Wow64Redirection) -> Self

Declare WOW64 filesystem redirection.

Source

pub const fn with_memory_priority(self, value: MemoryPriority) -> Self

Declare a memory priority.

Source

pub const fn with_background_mode(self, value: BackgroundMode) -> Self

Declare a background processing mode.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Declared

Source§

fn clone(&self) -> Declared

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Declared

Source§

impl Debug for Declared

Source§

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

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

impl Default for Declared

Source§

fn default() -> Declared

Returns the “default value” for a type. Read more
Source§

impl Eq for Declared

Source§

impl Hash for Declared

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Declared

Source§

fn eq(&self, other: &Declared) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Declared

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.