Trait musli::Allocator

source ·
pub trait Allocator {
    type Buf<'this>: Buf
       where Self: 'this;

    // Required method
    fn alloc(&self) -> Option<Self::Buf<'_>>;
}
Expand description

An allocator that can be used in combination with a context.

See the musli-allocator crate for examples.

Required Associated Types§

source

type Buf<'this>: Buf where Self: 'this

The type of an allocated buffer.

Required Methods§

source

fn alloc(&self) -> Option<Self::Buf<'_>>

Allocate an empty, uninitialized buffer.

Calling this method returns None if the allocation failed.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<A> Allocator for &A
where A: ?Sized + Allocator,

§

type Buf<'this> = <A as Allocator>::Buf<'this> where Self: 'this

source§

fn alloc(&self) -> Option<Self::Buf<'_>>

Implementors§