ntalloc 0.1.0

Windows kernel pool allocator (ExAllocatePool2) for no_std Rust drivers.
Documentation
[package]
name = "ntalloc"
version = "0.1.0"
edition = "2024"
rust-version = "1.85"
description = "Windows kernel pool allocator (ExAllocatePool2) for no_std Rust drivers."
license = "MIT OR Apache-2.0"
repository = "https://github.com/krakenaut9/ntalloc"
documentation = "https://docs.rs/ntalloc"
keywords = ["allocator", "kernel", "windows", "driver", "pool"]
categories = ["no-std", "os::windows-apis", "memory-management"]
include = ["src/**", "tests/**", "Cargo.toml", "README.md", "CHANGELOG.md", "LICENSE*"]
authors = ["Dmytro Maslo <krakenaut9@gmail.com>"]

[dependencies]
windows-sys = { version = "0.61", features = ["Wdk_System_SystemServices"] }
# The heap backend's table of live blocks: hashbrown's map, on memory from
# std's System allocator through allocator-api2, since std's own HashMap
# takes an allocator only on nightly. allocator-api2 must stay on the release
# line hashbrown uses (0.2), or System's impl lands on a different trait.
allocator-api2 = { version = "0.2.21", optional = true, default-features = false, features = ["std"] }
hashbrown = { version = "0.17", optional = true, default-features = false, features = ["allocator-api2"] }

[features]
# Implements the Allocator trait, so collections can use NtAlloc directly
# (Vec::new_in, Box::new_in). Needs Rust 1.100, where the trait is stable;
# without it the crate builds on 1.85.
allocator-api = []
# Implements the StaticAllocator and AllocatorClone marker traits, which are
# still unstable (allocator_ext): needs a nightly from October 2026 or later.
allocator-api-markers = ["allocator-api"]
# For tests only: allocates from the process heap instead of the kernel pool,
# so code using NtAlloc can run on a normal machine. Enable it only under
# [dev-dependencies].
usermode-backend = ["dep:allocator-api2", "dep:hashbrown"]

[dev-dependencies]
# Turns usermode-backend on for this crate's own tests. Packaging strips this,
# so the files in tests/ gate themselves on the feature.
ntalloc = { path = ".", features = ["usermode-backend"] }
# The unit tests run on the heap backend even without the feature, as they do
# in the packaged crate, where the line above is gone.
allocator-api2 = { version = "0.2.21", default-features = false, features = ["std"] }
hashbrown = { version = "0.17", default-features = false, features = ["allocator-api2"] }

# Runs without the standard test harness; tests/global_allocator.rs says why.
[[test]]
name = "global_allocator"
harness = false

# Kept here rather than in a CI command line so that a local `cargo clippy`
# matches CI. Groups take priority -1 so that single lints can override them.
[lints.clippy]
all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
# Every unsafe block says why it is sound.
undocumented_unsafe_blocks = "warn"

[package.metadata.docs.rs]
# The features that add API. usermode-backend adds none, and with it in the
# build rustdoc would also list its dependencies' blanket impls on NtAlloc.
features = ["allocator-api", "allocator-api-markers"]
# Windows only: docs.rs would otherwise also build Linux and macOS docs and
# open the crate on Linux.
targets = ["x86_64-pc-windows-msvc"]