Expand description
memapi
provides a no_std
-friendly memory allocation interface
for managing raw buffers, suitable for use in collections.
This crate exports:
Alloc
: a trait defining basic allocation, deallocation, grow, and shrink operations.DefaultAlloc
: a zero-cost wrapper delegating to the global allocator.AllocError
: an enum representing allocation failure cases.PtrProps
: property getters for pointers to values.SizedProps
: properties for sized types, similar to the unstable, hiddenSizedTypeProperties
.VarSized
: a marker trait for types withusize
metadata.UnsizedCopy
: a marker trait for safe copying of unsized values.Thin
: a marker trait for pointers without metadata.
§Features
-
alloc_ext
: Adds theAllocExt
trait for ergonomic allocator abstractions. -
alloc_slice
: Provides slice-based extensions:AllocSlice
for basic slice operations.- (with
alloc_ext
)AllocSliceExt
for advanced slice abstractions.
-
stats
: Collection of allocation statistics utilities:- [
StatsLogger
], a thread-safe logger for allocation events. - [
Stats
], an allocator wrapper that logs operations. - [
AllocRes
], [AllocStat
], [MemoryRegion
], [ResizeMemRegions
], [AllocKind
] types. - (With
std
) Several default logger implementations.
- [
-
external_alloc
: FFI helpers for external allocators. -
jemalloc
: Provides [Jemalloc
], a ZSTAlloc
implementation usingJemallocator
. -
mimalloc
: Provides [MiMalloc
], a ZSTAlloc
implementation usingMiMalloc
. -
nightly
: Enables using the unstableallocator_api
. -
metadata
,clone_to_uninit
,specialization
,sized_hierarchy
: Enable using the nightly Rust feature of the same name. -
extra_const
: Enables additionalconst
methods (MSRV ≥ 1.61.0). -
c_str
: ImplementsUnsizedCopy
forcore::ffi::CStr
(MSRV ≥ 1.64.0). -
extra_extra_const
: Further expandsconst
support (MSRV ≥ 1.83.0).
All other features are supersets of existing ones.
Modules§
- error
- Errors that can occur during allocation.
- ffi
- FFI bindings to allocation libraries.
- helpers
- Helpers that tend to be useful in other libraries as well.
- jemalloc
- Module for jemalloc support.
- marker
- Marker traits.
- mimalloc
- Module for mimalloc support.
- stats
- Allocation statistic gathering and reporting.
- type_
props - Sized type properties as constants and property getters for pointers.
- unstable_
util - Small alternatives to Rust functions that are unstable as of the most recent release.
Macros§
- atomic_
total_ ops - Helper macro to implement the default atomic total operations for a
StatsLogger
.
Structs§
- Default
Alloc - Default allocator, delegating to the global allocator.
Traits§
- Alloc
- A memory allocation interface.
- Alloc
Ext - Extension methods for the core
Alloc
trait, providing convenient routines to allocate, initialize, clone, copy, and deallocate sized and unsized types. - Alloc
Slice - Slice-specific extension methods for
Alloc
, providing convenient functions for slice allocator operations. - Alloc
Slice Ext - Slice-specific extension methods for
AllocExt
, providing extended convenient functions for slice allocator operations. - Resize
InPlace - Extension trait for
Alloc
which provides interfaces to reallocate in-place.