pub trait ComputeStorage: Send {
type Resource: Send;
// Required methods
fn alignment(&self) -> usize;
fn get(&mut self, handle: &StorageHandle) -> Self::Resource;
fn alloc(&mut self, size: u64) -> Result<StorageHandle, IoError>;
fn dealloc(&mut self, id: StorageId);
// Provided method
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) -> Self::Resource
fn get(&mut self, handle: &StorageHandle) -> Self::Resource
Returns the underlying resource for a specified storage handle
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.