Struct MaState

Source
pub struct MaState<'tree, T: ForeignOwnable> { /* private fields */ }
Expand description

A helper type used for navigating a MapleTree.

§Invariants

For the duration of 'tree:

  • The ma_state references a valid MapleTree<T>.
  • The ma_state has read/write access to the tree.

Implementations§

Source§

impl<'tree, T: ForeignOwnable> MaState<'tree, T>

Source

pub fn find(&mut self, max: usize) -> Option<T::BorrowedMut<'_>>

Find the next entry in the maple tree.

§Examples

Iterate the maple tree.

use kernel::maple_tree::MapleTree;
use kernel::sync::Arc;

let tree = KBox::pin_init(MapleTree::<Arc<i32>>::new(), GFP_KERNEL)?;

let ten = Arc::new(10, GFP_KERNEL)?;
let twenty = Arc::new(20, GFP_KERNEL)?;
tree.insert(100, ten, GFP_KERNEL)?;
tree.insert(200, twenty, GFP_KERNEL)?;

let mut ma_lock = tree.lock();
let mut iter = ma_lock.ma_state(0, usize::MAX);

assert_eq!(iter.find(usize::MAX).map(|v| *v), Some(10));
assert_eq!(iter.find(usize::MAX).map(|v| *v), Some(20));
assert!(iter.find(usize::MAX).is_none());

Auto Trait Implementations§

§

impl<'tree, T> Freeze for MaState<'tree, T>

§

impl<'tree, T> !RefUnwindSafe for MaState<'tree, T>

§

impl<'tree, T> !Send for MaState<'tree, T>

§

impl<'tree, T> !Sync for MaState<'tree, T>

§

impl<'tree, T> Unpin for MaState<'tree, T>

§

impl<'tree, T> !UnwindSafe for MaState<'tree, T>

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> Init<T> for T

Source§

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

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> PinInit<T> for T

Source§

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

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<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.