Skip to main content

os_dev_toolkit/
lib.rs

1//! # os_dev_toolkit
2//!
3//! Dependency-free, `no_std`-first building blocks intended to improve the *developer experience*
4//! while writing operating systems and kernels in Rust.
5//!
6//! ## Design goals
7//!
8//! - **`no_std` by default**: usable in kernels without a standard library.
9//! - **No external dependencies**: keeps builds deterministic and simplifies bring-up.
10//! - **Deterministic formatting/output**: logging and diagnostics avoid allocation by default.
11//! - **Small, composable primitives**: you decide integration details (serial/VGA/etc.).
12//!
13//! ## Features
14//!
15//! - `alloc`: reserved for future optional allocation-backed utilities.
16//! - `release_assertions`: keeps assertion macros enabled in release builds.
17//!
18//! ## High-level usage
19//!
20//! Most consumers will start with the [`crate::log`] module:
21//!
22//! ```rust
23//! use os_dev_toolkit::log::{Level, LogSink, Logger};
24//!
25//! struct MySink;
26//! impl LogSink for MySink {
27//!     fn write_str(&mut self, s: &str) {
28//!         let _ = s;
29//!         // forward to serial/vga/etc.
30//!     }
31//! }
32//!
33//! fn demo() {
34//!     let mut sink = MySink;
35//!     let mut logger = Logger::new(&mut sink, Level::Info);
36//!     os_dev_toolkit::kinfo!(logger, "hello from the kernel side: {}", 123);
37//! }
38//! ```
39//!
40//! ## Safety and concurrency
41//!
42//! This crate provides synchronization primitives such as [`sync::SpinLock`] and [`sync::Once`].
43//! These are intentionally minimal and do **not** attempt to be fair or preemption-safe; you must
44//! apply the right interrupt/preemption masking strategy for your kernel.
45#![no_std]
46#![deny(warnings)]
47
48/// Assertion macros suitable for kernel/OS environments.
49pub mod assert;
50/// Fixed-capacity data structures (`RingBuffer`, `FixedStr`) intended for allocation-free code.
51pub mod buffer;
52/// Deterministic formatting helpers such as hexdumps and byte-size formatters.
53pub mod fmt;
54/// Minimal logging traits and a small `Logger` with level filtering.
55pub mod log;
56/// Panic helpers for routing panic output to a sink and halting.
57pub mod panic;
58/// OS-style status codes and small conversion helpers.
59pub mod status;
60/// Simple synchronization primitives (`SpinLock`, `Once`) for `no_std` environments.
61pub mod sync;
62
63/// Compile-time configuration helpers.
64pub mod config;