pub trait ComputeStorage: Send {
type Resource: Send;
// Required methods
fn alignment(&self) -> usize;
fn get(&mut self, handle: &StorageHandle) -> Result<Self::Resource, IoError>;
fn alloc(&mut self, size: u64) -> Result<StorageHandle, IoError>;
fn dealloc(&mut self, id: StorageId);
fn flush(&mut self);
}Expand description
Storage types are responsible for allocating and deallocating memory.
Required Associated Types§
Required Methods§
Sourcefn get(&mut self, handle: &StorageHandle) -> Result<Self::Resource, IoError>
fn get(&mut self, handle: &StorageHandle) -> Result<Self::Resource, IoError>
Returns the underlying resource for a specified storage handle.
§Errors
IoError::StorageHandleNotFound when this storage holds no
allocation for the handle’s id — a handle that outlived its allocation,
or one whose id a deallocation retired.
Sourcefn alloc(&mut self, size: u64) -> Result<StorageHandle, IoError>
fn alloc(&mut self, size: u64) -> Result<StorageHandle, IoError>
Allocates size units of memory and returns a handle to it
Sourcefn dealloc(&mut self, id: StorageId)
fn dealloc(&mut self, id: StorageId)
Deallocates the memory pointed by the given storage id.
These deallocations might need to be flushed with Self::flush.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".