Skip to main content

Crate citadel_io

Crate citadel_io 

Source
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_lot for 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§

standard

Enums§

Error
Represents errors that can occur during I/O operations

Traits§

CryptoRng
A marker trait used to indicate that an RngCore or BlockRngCore implementation is supposed to be cryptographically secure.
Distribution
Types (distributions) that can be used to create a random instance of T.
IteratorRandom
Extension trait on iterators, providing random sampling methods.
Rng
An automatically-implemented extension trait on RngCore providing high-level generic methods for sampling values and other convenience methods.
RngCore
The core of a random number generator.
SeedableRng
A random number generator that can be explicitly seeded.
SliceRandom
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.