Struct CpumaskVar

Source
pub struct CpumaskVar { /* private fields */ }
Expand description

A CPU Mask pointer.

Rust abstraction for the C struct cpumask_var_t.

§Invariants

A CpumaskVar instance always corresponds to a valid C struct cpumask_var_t.

The callers must ensure that the struct cpumask_var_t is valid for access and remains valid for the lifetime of CpumaskVar.

§Examples

The following example demonstrates how to create and update a CpumaskVar.

use kernel::cpumask::CpumaskVar;

let mut mask = CpumaskVar::new_zero(GFP_KERNEL).unwrap();

assert!(mask.empty());
mask.set(2);
assert!(mask.test(2));
mask.set(3);
assert!(mask.test(3));
assert_eq!(mask.weight(), 2);

let mask2 = CpumaskVar::try_clone(&mask).unwrap();
assert!(mask2.test(2));
assert!(mask2.test(3));
assert_eq!(mask2.weight(), 2);

Implementations§

Source§

impl CpumaskVar

Source

pub fn new_zero(_flags: Flags) -> Result<Self, AllocError>

Creates a zero-initialized instance of the CpumaskVar.

Source

pub unsafe fn new(_flags: Flags) -> Result<Self, AllocError>

Creates an instance of the CpumaskVar.

§Safety

The caller must ensure that the returned CpumaskVar is properly initialized before getting used.

Source

pub unsafe fn as_mut_ref<'a>(ptr: *mut cpumask_var_t) -> &'a mut Self

Creates a mutable reference to an existing struct cpumask_var_t pointer.

§Safety

The caller must ensure that ptr is valid for writing and remains valid for the lifetime of the returned reference.

Source

pub unsafe fn as_ref<'a>(ptr: *const cpumask_var_t) -> &'a Self

Creates a reference to an existing struct cpumask_var_t pointer.

§Safety

The caller must ensure that ptr is valid for reading and remains valid for the lifetime of the returned reference.

Source

pub fn try_clone(cpumask: &Cpumask) -> Result<Self>

Clones cpumask.

Methods from Deref<Target = Cpumask>§

Source

pub fn as_raw(&self) -> *mut cpumask

Obtain the raw struct cpumask pointer.

Source

pub fn set(&mut self, cpu: u32)

Set cpu in the cpumask.

ATTENTION: Contrary to C, this Rust set() method is non-atomic. This mismatches kernel naming convention and corresponds to the C function __cpumask_set_cpu().

Source

pub fn clear(&mut self, cpu: i32)

Clear cpu in the cpumask.

ATTENTION: Contrary to C, this Rust clear() method is non-atomic. This mismatches kernel naming convention and corresponds to the C function __cpumask_clear_cpu().

Source

pub fn test(&self, cpu: i32) -> bool

Test cpu in the cpumask.

Equivalent to the kernel’s cpumask_test_cpu API.

Source

pub fn setall(&mut self)

Set all CPUs in the cpumask.

Equivalent to the kernel’s cpumask_setall API.

Source

pub fn empty(&self) -> bool

Checks if cpumask is empty.

Equivalent to the kernel’s cpumask_empty API.

Source

pub fn full(&self) -> bool

Checks if cpumask is full.

Equivalent to the kernel’s cpumask_full API.

Source

pub fn weight(&self) -> u32

Get weight of the cpumask.

Equivalent to the kernel’s cpumask_weight API.

Source

pub fn copy(&self, dstp: &mut Self)

Copy cpumask.

Equivalent to the kernel’s cpumask_copy API.

Trait Implementations§

Source§

impl Deref for CpumaskVar

Source§

type Target = Cpumask

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for CpumaskVar

Source§

fn deref_mut(&mut self) -> &mut Cpumask

Mutably dereferences the value.
Source§

impl Drop for CpumaskVar

Source§

fn drop(&mut self)

Executes the destructor for this type. 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, E> Init<T, E> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
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, E> PinInit<T, E> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.