Allocator

Trait Allocator 

Source
pub trait Allocator<B: Backend> {
    type Block: Block<B>;

    const KIND: Kind;

    // Required methods
    fn alloc(
        &mut self,
        device: &B::Device,
        size: Size,
        align: Size,
    ) -> Result<(Self::Block, Size), AllocationError>;
    fn free(&mut self, device: &B::Device, block: Self::Block) -> Size;
}
Expand description

Allocator trait implemented for various allocators.

Required Associated Constants§

Source

const KIND: Kind

Allocator kind.

Required Associated Types§

Source

type Block: Block<B>

Block type returned by allocator.

Required Methods§

Source

fn alloc( &mut self, device: &B::Device, size: Size, align: Size, ) -> Result<(Self::Block, Size), AllocationError>

Allocate block of memory. On success returns allocated block and amount of memory consumed from device.

Source

fn free(&mut self, device: &B::Device, block: Self::Block) -> Size

Free block of memory. Returns amount of memory returned to the device.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<B: Backend> Allocator<B> for DedicatedAllocator

Source§

const KIND: Kind = Kind::Dedicated

Source§

type Block = DedicatedBlock<B>

Source§

impl<B: Backend> Allocator<B> for GeneralAllocator<B>

Source§

const KIND: Kind = Kind::General

Source§

type Block = GeneralBlock<B>

Source§

impl<B: Backend> Allocator<B> for LinearAllocator<B>

Source§

const KIND: Kind = Kind::Linear

Source§

type Block = LinearBlock<B>