pub struct DictStore {
pub entities: EntityTable,
/* private fields */
}Expand description
Storage for all PostScript dictionaries.
The entity table maps EntityId → index into dicts. For Phase 2 this is
a 1:1 mapping (entity N → dicts[N]), but the indirection enables
save_level tracking and future COW.
Fields§
§entities: EntityTableImplementations§
Source§impl DictStore
impl DictStore
pub fn new() -> Self
Sourcepub fn allocate(&mut self, max_length: usize, name: &[u8]) -> EntityId
pub fn allocate(&mut self, max_length: usize, name: &[u8]) -> EntityId
Allocate a new dictionary with the given maximum length and name.
Sourcepub fn allocate_with(
&mut self,
max_length: usize,
name: &[u8],
save_level: u16,
global: bool,
created_after_save: u32,
) -> EntityId
pub fn allocate_with( &mut self, max_length: usize, name: &[u8], save_level: u16, global: bool, created_after_save: u32, ) -> EntityId
Allocate with a specific save level and global flag.
Sourcepub fn get(&self, entity: EntityId, key: &DictKey) -> Option<PsObject>
pub fn get(&self, entity: EntityId, key: &DictKey) -> Option<PsObject>
Look up a key in a dictionary.
Sourcepub fn put(&mut self, entity: EntityId, key: DictKey, value: PsObject)
pub fn put(&mut self, entity: EntityId, key: DictKey, value: PsObject)
Insert or update a key-value pair.
Sourcepub fn max_length(&self, entity: EntityId) -> usize
pub fn max_length(&self, entity: EntityId) -> usize
Maximum capacity.
Sourcepub fn keys(&self, entity: EntityId) -> impl Iterator<Item = &DictKey>
pub fn keys(&self, entity: EntityId) -> impl Iterator<Item = &DictKey>
Iterate over keys of a dictionary.
Sourcepub fn require_read(&self, entity: EntityId) -> Result<(), PsError>
pub fn require_read(&self, entity: EntityId) -> Result<(), PsError>
Require read access on a dict. Returns InvalidAccess if access < READ_ONLY.
Sourcepub fn require_write(&self, entity: EntityId) -> Result<(), PsError>
pub fn require_write(&self, entity: EntityId) -> Result<(), PsError>
Require write access on a dict. Returns InvalidAccess if access < UNLIMITED.
Sourcepub fn set_access(&mut self, entity: EntityId, access: u8)
pub fn set_access(&mut self, entity: EntityId, access: u8)
Set the access level of a dictionary.
Sourcepub fn cow_copy(&mut self, entity: EntityId) -> EntityId
pub fn cow_copy(&mut self, entity: EntityId) -> EntityId
Copy a dictionary’s contents to a new dict (for COW). Returns the new EntityId. The original entity is updated to point at the copy; the returned entity points at the original data (the backup).
Sourcepub fn swap_offsets(&mut self, a: EntityId, b: EntityId)
pub fn swap_offsets(&mut self, a: EntityId, b: EntityId)
Swap indices between two entities (used by restore).