ic_memory/slot/
descriptor.rs1use super::memory_manager::MemoryManagerSlotError;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
12#[serde(deny_unknown_fields)]
13pub enum AllocationSlot {
14 MemoryManagerId(u8),
16}
17
18#[derive(Clone, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
27#[serde(deny_unknown_fields)]
28pub struct AllocationSlotDescriptor {
29 pub(crate) slot: AllocationSlot,
31}
32
33impl AllocationSlotDescriptor {
34 #[must_use]
36 pub const fn slot(&self) -> &AllocationSlot {
37 &self.slot
38 }
39
40 pub fn validate(&self) -> Result<(), MemoryManagerSlotError> {
42 self.memory_manager_id().map(|_| ())
43 }
44}