akern-gkgoat-fork/ableos/src/handle.rs
TheOddGarlic 69c10e0ba4 misc warning fixes
this concludes the fix warnings phase of the cleanup
2022-08-01 14:50:41 +03:00

49 lines
1 KiB
Rust

//! A handle is a u128 with a set of permissions
//! and a resource connected to it
use crate::arch::generate_process_pass;
use core::fmt::Display;
#[derive(Debug)]
pub struct BinaryData {
_name: String,
_data: Vec<u8>,
}
#[derive(Debug, Eq, Hash, PartialEq, Clone, Copy)]
pub enum HandleResource {
Channel,
Socket,
BinaryData,
}
#[derive(Debug, Eq, Hash, PartialEq, Clone, Copy)]
pub struct Handle {
pub inner: u128,
pub res: HandleResource,
}
impl Display for Handle {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "Handle-{:032x}", self.inner)?;
match &self.res {
HandleResource::Channel => write!(f, "-Channel")?,
HandleResource::BinaryData => write!(f, "-Binary")?,
Socket => write!(f, "-Socket")?,
}
Ok(())
}
}
use crate::handle::HandleResource::*;
impl Handle {
pub fn new(htype: HandleResource) -> Self {
Self {
inner: generate_process_pass(),
res: htype,
}
}
}