capsules_system/storage_permissions/
individual.rsuse kernel::capabilities::ApplicationStorageCapability;
use kernel::platform::chip::Chip;
use kernel::process::Process;
use kernel::process::ShortId;
use kernel::storage_permissions::StoragePermissions;
pub struct IndividualStoragePermissions<
C: Chip,
D: kernel::process::ProcessStandardDebug,
CAP: ApplicationStorageCapability,
> {
cap: CAP,
_chip: core::marker::PhantomData<C>,
_debug: core::marker::PhantomData<D>,
}
impl<C: Chip, D: kernel::process::ProcessStandardDebug, CAP: ApplicationStorageCapability>
IndividualStoragePermissions<C, D, CAP>
{
pub fn new(cap: CAP) -> Self {
Self {
cap,
_chip: core::marker::PhantomData,
_debug: core::marker::PhantomData,
}
}
}
impl<C: Chip, D: kernel::process::ProcessStandardDebug, CAP: ApplicationStorageCapability>
kernel::process::ProcessStandardStoragePermissionsPolicy<C, D>
for IndividualStoragePermissions<C, D, CAP>
{
fn get_permissions(
&self,
process: &kernel::process::ProcessStandard<C, D>,
) -> StoragePermissions {
match process.short_app_id() {
ShortId::Fixed(id) => StoragePermissions::new_self_only(id, &self.cap),
ShortId::LocallyUnique => StoragePermissions::new_null(),
}
}
}