Struct HandleTable

Source
pub struct HandleTable {
    handles: [Option<KernelObject>; 1024],
    metadata: [Option<HandleMetadata>; 1024],
    free_handles: Vec<Handle>,
}

Fields§

§handles: [Option<KernelObject>; 1024]

Fixed-size handle table

§metadata: [Option<HandleMetadata>; 1024]

Metadata for each handle

§free_handles: Vec<Handle>

Stack of available handle numbers for O(1) allocation

Implementations§

Source§

impl HandleTable

Source

const MAX_HANDLES: usize = 1_024usize

Source

pub fn new() -> Self

Source

pub fn insert(&mut self, obj: KernelObject) -> Result<Handle, &'static str>

O(1) allocation with automatic metadata inference

Source

pub fn insert_with_metadata( &mut self, obj: KernelObject, metadata: HandleMetadata, ) -> Result<Handle, &'static str>

O(1) allocation with explicit metadata

Source

fn infer_metadata_from_object(object: &KernelObject) -> HandleMetadata

Infer metadata from KernelObject type and usage context

This function provides reasonable defaults for handle roles based on the KernelObject type. Applications can override this by using insert_with_metadata() to specify exact roles.

Source

pub fn get(&self, handle: Handle) -> Option<&KernelObject>

O(1) access

Source

pub fn remove(&mut self, handle: Handle) -> Option<KernelObject>

O(1) removal

Source

pub fn update_metadata( &mut self, handle: Handle, new_metadata: HandleMetadata, ) -> Result<(), &'static str>

Update metadata for an existing handle

Source

pub fn open_count(&self) -> usize

Get the number of open handles

Source

pub fn active_handles(&self) -> Vec<Handle>

Get all active handles

Source

pub fn close_all(&mut self)

Close all handles (for process termination)

Source

pub fn is_valid_handle(&self, handle: Handle) -> bool

Check if a handle is valid

Source

pub fn get_metadata(&self, handle: Handle) -> Option<&HandleMetadata>

Get metadata for a handle

Source

pub fn iter_with_metadata( &self, ) -> impl Iterator<Item = (Handle, &KernelObject, &HandleMetadata)>

Iterator over handles with their objects and metadata

Source

pub fn get_object_info(&self, handle: Handle) -> Option<KernelObjectInfo>

Get detailed information about a KernelObject for user space introspection

Trait Implementations§

Source§

impl Clone for HandleTable

Source§

fn clone(&self) -> HandleTable

Returns a copy of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Default for HandleTable

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for HandleTable

§

impl !RefUnwindSafe for HandleTable

§

impl Send for HandleTable

§

impl Sync for HandleTable

§

impl Unpin for HandleTable

§

impl !UnwindSafe for HandleTable

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.