pub struct MetaState { /* private fields */ }Expand description
Ghost state for verification (not runtime)
Corresponds to Lean: structure MetaState
This tracks resource lifecycle for proofs about temporal safety. At runtime, only the freed_set is used for double-free prevention.
Implementations§
Source§impl MetaState
impl MetaState
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Create empty meta state
Corresponds to Lean: def MetaState.empty : MetaState
Sourcepub fn is_live(&self, addr: MemAddr) -> bool
pub fn is_live(&self, addr: MemAddr) -> bool
Check if resource is live (allocated and not freed)
Corresponds to Lean: def MetaState.is_live (ms : MetaState) (addr : MemAddr) : Prop
Sourcepub fn alloc(&self, addr: MemAddr, owner: PluginId) -> Self
pub fn alloc(&self, addr: MemAddr, owner: PluginId) -> Self
Mark resource as allocated
Corresponds to Lean: def MetaState.alloc
Returns the new MetaState with the resource marked as allocated.
Sourcepub fn free(&self, addr: MemAddr) -> Self
pub fn free(&self, addr: MemAddr) -> Self
Mark resource as freed
Corresponds to Lean: def MetaState.free
Data Refinement Note (from Lean): The resources field is NOT updated.
Only freed_set is used for double-free prevention.
Sourcepub fn alloc_mut(&mut self, addr: MemAddr, owner: PluginId)
pub fn alloc_mut(&mut self, addr: MemAddr, owner: PluginId)
Mark resource as allocated (mutating version)
Sourcepub fn free_mut(&mut self, addr: MemAddr) -> Result<(), MemoryError>
pub fn free_mut(&mut self, addr: MemAddr) -> Result<(), MemoryError>
Mark resource as freed (mutating version)
Requires the resource to be currently allocated. Updates the resource
status to Freed and adds the address to the freed set.
§Errors
Returns MemoryError::DoubleFree if the address has already been freed.
Returns MemoryError::NotAllocated if the address was never allocated.
Sourcepub fn allocated_count(&self) -> usize
pub fn allocated_count(&self) -> usize
Get the number of allocated resources
Sourcepub fn freed_count(&self) -> usize
pub fn freed_count(&self) -> usize
Get the number of freed resources
Sourcepub fn resource_count(&self) -> usize
pub fn resource_count(&self) -> usize
Get the number of resources in the map
Sourcepub fn get_status(&self, addr: MemAddr) -> Option<&ResourceStatus>
pub fn get_status(&self, addr: MemAddr) -> Option<&ResourceStatus>
Get the status of a resource