#![deny(missing_docs)]
pub mod executor;
pub mod fs;
pub mod io;
pub mod net;
pub mod sync;
pub mod timer;
pub use io::{
AsyncBufRead, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, MoiraiCompat, TokioCompat,
};
pub use executor::{AsyncExecutor, AsyncHandle, ExecutorStats};
pub use timer::{
interval, interval_at, sleep, timeout, Delay, Interval, RateLimiter, RatePermit, Timeout,
TimeoutError, TimerCommand, TimerWheel,
};
pub use net::{
ConnectionInfo, ConnectionPool, ConnectionStats, TcpListener, TcpServerConfig, TcpServerStats,
TcpStream, UdpConfig, UdpSocket, UdpSocketStats,
};
pub use fs::{
append, append_str, copy, create_dir, create_dir_all, metadata, read, read_to_string,
remove_dir, remove_dir_all, remove_file, rename, write, write_str, File, FileOpenOptions,
FileStats,
};
pub use sync::{
Broadcast, BroadcastError, BroadcastReceiver, BroadcastSender, Condvar, Mutex, MutexGuard,
Notify, RwLock, Semaphore, SemaphorePermit, Watch, WatchError, WatchReceiver, WatchSender,
};
pub use moirai_async_macros::main;
#[cfg(test)]
mod tests {
use super::*;
use std::time::Duration;
#[test]
fn test_integration_async_executor() {
let executor = AsyncExecutor::new().expect("Failed to create executor");
let _handle = executor.spawn(async {
moirai_pal::timer::sleep(Duration::from_millis(10))
.await
.ok();
"async task completed"
});
let stats_before = executor.stats();
assert_eq!(stats_before.tasks_spawned, 1);
assert_eq!(stats_before.tasks_pending, 1);
}
#[test]
fn test_integration_executor_stats() {
let executor = AsyncExecutor::new().expect("Failed to create executor");
let stats = executor.stats();
assert_eq!(stats.tasks_spawned, 0);
assert_eq!(stats.tasks_completed, 0);
assert_eq!(stats.tasks_pending, 0);
assert_eq!(stats.io_operations, 0);
}
#[test]
fn test_integration_reactor_access() {
let executor = AsyncExecutor::new().expect("Failed to create executor");
let _reactor = executor.reactor();
}
}