NSTD

A cross-platform, fast, and safe general purpose C library written in Rust.

The library is organized as a series of modules. The top level module nstd encompasses the entire crate. Each module can have their own submodules (eg. nstd.core.def or nstd::core::def with Rust syntax).

Modules

Platform support

nstd.core should support anything that rustc supports.

nstd.os's child modules will only work on the operating system they target. For example, nstd.os.windows will only work on Windows and nstd.os.linux will only work on Linux distributions.

Other modules will work on most platforms, primarily targeting Windows, macOS, Linux, Android, and iOS.

Language support

This library can be accessed from any language that supports calling C code! As of now this will need to be done manually as there are no official wrappers for the API, however whenever library versioning occurs, the plan is to start adding official wrappers so developers from other languages can easily use the API.

Safety notes

nstd tries it's best to comply with Rust's safety. This means anything that can cause undefined behavior is considered unsafe (with the exception of functions that take Rusty references, which always assume a non-null argument). However nstd is a C library, and we do not have access to the borrow checker in C, and making every function that borrows data mutably "unsafe" would not be ideal. I am always looking for ways to make this API as safe as sanely possible, so please open an issue if you have any ideas on how we can do so, it would be greatly appreciated.

How to build

nstd let you decide what features you want to use. Any module that falls under the top level module has a dedicated feature flag, for example nstd.core has the feature flag nstd_core and nstd.alloc has the feature flag nstd_alloc. Each module can also have additional features, for example nstd.os has the additional nstd_os_windows_alloc feature for memory allocation on Windows, this allows other modules to use the low level memory allocation API for Windows without enabling memory allocation support for other operating systems. To build nstd as a C library, use the clib feature flag. The std feature flag enables Rust standard library support. std and nstd_core are enabled by default.

For example: sh cargo build --release --features "clib nstd_alloc nstd_vec"

To build with all features: sh cargo build --release --all-features