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 withusizemetadata.UnsizedCopy: a marker trait for safe copying of unsized values.Thin: a marker trait for pointers without metadata.
§Features
-
alloc_ext: Adds theAllocExttrait for ergonomic allocator abstractions. -
alloc_slice: Provides slice-based extensions:AllocSlicefor basic slice operations.- (with
alloc_ext)AllocSliceExtfor 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. - (With
stats_file_lock) Safer file locking forFileLog. (MSRV ≥ 1.89.0). - (With
stats_parking_lot) Usage ofparking_lot::Mutexinstead ofstd::sync::Mutex.
- [
-
external_alloc: FFI helpers for external allocators. -
os_err_reporting: Enables OS error reporting on failed allocation for supported allocators.- Supported allocators: Jemalloc, Rust’s default,
MiMallocifmimalloc_err_reportingis enabled.
- Supported allocators: Jemalloc, Rust’s default,
-
jemalloc: Provides [Jemalloc], a ZSTAllocimplementation usingJemallocator. -
mimalloc: Provides [MiMalloc], a ZSTAllocimplementation usingMiMalloc.mimalloc_err_reporting: Enables OS error reporting on failed allocation forMiMalloc.mimalloc_error_output: Enables OS error reporting AND printing to stderr on failed allocation forMiMalloc.
-
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 additionalconstmethods (MSRV ≥ 1.61.0). -
c_str: ImplementsUnsizedCopyforcore::ffi::CStr(MSRV ≥ 1.64.0). -
extra_extra_const: Further expandsconstsupport (MSRV ≥ 1.83.0).
All other features are either bundles of others or bindings to MiMalloc/Jemalloc’s features.
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
Alloctrait, 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
Allocwhich provides interfaces to reallocate in-place.