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
impl HandleTable
const MAX_HANDLES: usize = 1_024usize
pub fn new() -> Self
Sourcepub fn insert(&mut self, obj: KernelObject) -> Result<Handle, &'static str>
pub fn insert(&mut self, obj: KernelObject) -> Result<Handle, &'static str>
O(1) allocation with automatic metadata inference
Sourcepub fn insert_with_metadata(
&mut self,
obj: KernelObject,
metadata: HandleMetadata,
) -> Result<Handle, &'static str>
pub fn insert_with_metadata( &mut self, obj: KernelObject, metadata: HandleMetadata, ) -> Result<Handle, &'static str>
O(1) allocation with explicit metadata
Sourcefn infer_metadata_from_object(object: &KernelObject) -> HandleMetadata
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.
Sourcepub fn get(&self, handle: Handle) -> Option<&KernelObject>
pub fn get(&self, handle: Handle) -> Option<&KernelObject>
O(1) access
Sourcepub fn remove(&mut self, handle: Handle) -> Option<KernelObject>
pub fn remove(&mut self, handle: Handle) -> Option<KernelObject>
O(1) removal
Sourcepub fn update_metadata(
&mut self,
handle: Handle,
new_metadata: HandleMetadata,
) -> Result<(), &'static str>
pub fn update_metadata( &mut self, handle: Handle, new_metadata: HandleMetadata, ) -> Result<(), &'static str>
Update metadata for an existing handle
Sourcepub fn open_count(&self) -> usize
pub fn open_count(&self) -> usize
Get the number of open handles
Sourcepub fn active_handles(&self) -> Vec<Handle>
pub fn active_handles(&self) -> Vec<Handle>
Get all active handles
Sourcepub fn is_valid_handle(&self, handle: Handle) -> bool
pub fn is_valid_handle(&self, handle: Handle) -> bool
Check if a handle is valid
Sourcepub fn get_metadata(&self, handle: Handle) -> Option<&HandleMetadata>
pub fn get_metadata(&self, handle: Handle) -> Option<&HandleMetadata>
Get metadata for a handle
Sourcepub fn iter_with_metadata(
&self,
) -> impl Iterator<Item = (Handle, &KernelObject, &HandleMetadata)>
pub fn iter_with_metadata( &self, ) -> impl Iterator<Item = (Handle, &KernelObject, &HandleMetadata)>
Iterator over handles with their objects and metadata
Sourcepub fn get_object_info(&self, handle: Handle) -> Option<KernelObjectInfo>
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
impl Clone for HandleTable
Source§fn clone(&self) -> HandleTable
fn clone(&self) -> HandleTable
Returns a copy of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto 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 Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)