use crate::error::Result;
use core::ptr::NonNull;
#[cfg(not(feature = "std"))]
use alloc::boxed::Box;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum MemoryKind {
Device,
Pinned,
Unified,
Constant,
Shared,
Texture,
}
pub trait Allocation: Send + Sync {
fn kind(&self) -> MemoryKind;
fn len_bytes(&self) -> usize;
fn as_ptr(&self) -> NonNull<u8>;
}
pub trait MemoryPool: Send + Sync {
fn kind(&self) -> MemoryKind;
fn alloc(&self, bytes: usize, align: usize) -> Result<Box<dyn Allocation>>;
fn trim(&self) {}
}