Expand description
§Citadel IO
A cross-platform I/O utility crate that provides consistent interfaces for both native and WebAssembly targets. This crate abstracts platform-specific implementations of common I/O operations, synchronization primitives, and random number generation.
§Features
- Cross-platform synchronization primitives (
Mutex,RwLock) - Platform-specific random number generation
- Deadlock detection (native only)
- Async runtime abstractions via Tokio
- WebAssembly-compatible implementations
§Platform Support
§Native (non-WASM)
On native platforms, this crate uses:
parking_lotfor high-performance synchronization primitives- Standard Tokio for async runtime
- System random number generator
- Optional deadlock detection
§WebAssembly
On WASM targets, this crate provides:
- WebAssembly-compatible synchronization primitives
- WASM-specific random number generation
- WASM-compatible Tokio implementation
§Usage
use citadel_io::{Mutex, RwLock, ThreadRng};
// Create thread-safe synchronization primitives
let mutex = Mutex::new(42);
let rwlock = RwLock::new(String::new());
// Use locks safely across threads
{
let mut guard = mutex.lock();
*guard += 1;
}
// Read-write lock usage
{
let mut writer = rwlock.write();
writer.push_str("Hello");
}Re-exports§
pub use tokio;pub use tokio_util;pub use tokio_stream;pub use standard::locks::*;
Modules§
Enums§
- Error
- Represents errors that can occur during I/O operations
Traits§
- Crypto
Rng - A marker trait used to indicate that an
RngCoreorBlockRngCoreimplementation is supposed to be cryptographically secure. - Distribution
- Types (distributions) that can be used to create a random instance of
T. - Iterator
Random - Extension trait on iterators, providing random sampling methods.
- Rng
- An automatically-implemented extension trait on
RngCoreproviding high-level generic methods for sampling values and other convenience methods. - RngCore
- The core of a random number generator.
- Seedable
Rng - A random number generator that can be explicitly seeded.
- Slice
Random - Extension trait on slices, providing random mutation and sampling methods.
Functions§
- const_
mutex - Creates a new mutex in an unlocked state ready for use.
- const_
rwlock - Creates a new instance of an
RwLock<T>which is unlocked.