2022-01-25 19:40:37 -06:00
|
|
|
use alloc::vec::Vec;
|
|
|
|
|
2022-01-26 19:43:03 -06:00
|
|
|
use crate::file::PathRep;
|
|
|
|
|
2022-01-25 19:40:37 -06:00
|
|
|
pub type SoundCardID = u8;
|
|
|
|
pub type DeviceID = u8;
|
|
|
|
pub type ControllerID = u8;
|
|
|
|
|
2022-01-26 19:43:03 -06:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2022-01-25 19:40:37 -06:00
|
|
|
pub enum FileAccess {
|
|
|
|
All,
|
2022-01-26 19:43:03 -06:00
|
|
|
Some(Vec<PathRep>),
|
2022-01-25 19:40:37 -06:00
|
|
|
None,
|
|
|
|
}
|
|
|
|
|
2022-01-26 19:43:03 -06:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2022-01-25 19:40:37 -06:00
|
|
|
pub enum ControllerAccess {
|
|
|
|
All,
|
|
|
|
Some(Vec<ControllerID>),
|
|
|
|
None,
|
|
|
|
}
|
|
|
|
|
2022-01-26 19:43:03 -06:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2022-01-25 19:40:37 -06:00
|
|
|
pub enum SoundCardAccess {
|
|
|
|
All,
|
|
|
|
Some(Vec<SoundCardID>),
|
|
|
|
None,
|
|
|
|
}
|
|
|
|
|
2022-01-26 19:43:03 -06:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2022-01-25 19:40:37 -06:00
|
|
|
pub enum MouseAccess {
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
}
|
|
|
|
|
2022-01-26 19:43:03 -06:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2022-01-25 19:40:37 -06:00
|
|
|
pub enum KeyboardAccess {
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
}
|
|
|
|
|
2022-01-26 19:43:03 -06:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub enum NetworkAccess {
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// A set of capabilities that a process has
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2022-01-25 19:40:37 -06:00
|
|
|
pub struct Capabilities {
|
2022-01-26 19:43:03 -06:00
|
|
|
pub files: FileAccess,
|
|
|
|
pub mouse: MouseAccess,
|
|
|
|
pub keyboard: KeyboardAccess,
|
|
|
|
pub controllers: ControllerAccess,
|
|
|
|
pub sound_cards: SoundCardAccess,
|
|
|
|
|
|
|
|
pub network_access: NetworkAccess,
|
2022-01-25 19:40:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Capabilities {
|
|
|
|
/// Generate a set of empty capabilities
|
|
|
|
pub fn empty() -> Self {
|
|
|
|
Self {
|
|
|
|
files: FileAccess::None,
|
|
|
|
mouse: MouseAccess::No,
|
|
|
|
keyboard: KeyboardAccess::No,
|
|
|
|
controllers: ControllerAccess::None,
|
|
|
|
sound_cards: SoundCardAccess::None,
|
2022-01-26 19:43:03 -06:00
|
|
|
network_access: NetworkAccess::No,
|
2022-01-25 19:40:37 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|