Skip to main content

Crate memapi2

Crate memapi2 

Source
Expand description

A small, no_std/no_alloc-friendly memory allocation interface for managing raw buffers.

This crate provides explicit layouts, a split allocator trait stack, and structured errors. It is no_std by default but relies on the alloc crate unless no_alloc is enabled. Enable std for system allocator integrations and os_err_reporting for richer diagnostics.

§Core traits

§Types and errors

§Data and type utilities

§Allocator implementations

  • DefaultAlloc (available unless no_alloc is enabled and std isn’t)
  • System when the std feature is enabled
  • CAlloc behind the c_alloc feature
  • StackAlloc behind the stack_alloc feature

§Feature flags

  • no_alloc disables usage of the rust alloc crate; std crate is used instead if the std feature is enabled.
  • std: enables std integration (including System)
  • os_err_reporting: best-effort OS error reporting via errno (requires std)
  • alloc_temp_trait: scoped/temporary allocation trait
  • c_alloc: C posix_memalign-style allocator (allocs::c_alloc)
  • stack_alloc: alloca-based allocator (allocs::stack_alloc)
  • c_str: enables CStr-specific data traits in no_std (MSRV: 1.64)
  • metadata: enables core::ptr::Pointee metadata support on nightly
  • sized_hierarchy: enables core::marker::MetaSized support on nightly
  • full, full_nightly: convenience bundles

Modules§

allocs
Additional allocators which this crate supports.
error
Errors that can occur during allocation.
ffi
FFI backing any extra enabled allocators.
helpers
Helpers that tend to be useful in other libraries as well.
layout
A custom layout type to get around some strange Rust stdlib limitations.
prelude
A relatively minimal prelude containing the most common, important things from this crate.
traits
All traits provided by this crate.

Structs§

DefaultAlloc
Default allocator, delegating to the global allocator.