#![deny(missing_docs)]
mod blocking;
#[cfg(not(target_arch = "wasm32"))]
pub mod executor;
pub mod fs;
pub mod io;
#[cfg(any(unix, windows))]
pub mod net;
pub mod sync;
pub mod timer;
pub use io::{
AsyncBufRead, AsyncLength, AsyncMemReader, AsyncRead, AsyncReadAt, AsyncReadExt, AsyncWrite,
AsyncWriteExt, MoiraiCompat, TokioCompat,
};
#[cfg(not(target_arch = "wasm32"))]
pub use executor::{AsyncExecutor, AsyncHandle, ExecutorStats};
pub use timer::{
Delay, Interval, RateLimiter, RatePermit, Timeout, TimeoutError, TimerCommand, TimerWheel,
interval, interval_at, sleep, timeout,
};
#[cfg(any(unix, windows))]
pub use net::{
ConnectionInfo, ConnectionPool, ConnectionStats, TcpListener, TcpServerConfig, TcpServerStats,
TcpStream, UdpConfig, UdpSocket, UdpSocketStats,
};
pub use fs::{
File, FileOpenOptions, FileStats, 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,
};
pub use sync::{
Broadcast, BroadcastError, BroadcastReceiver, BroadcastSender, Condvar, Mutex, MutexGuard,
Notify, RwLock, Semaphore, SemaphorePermit, Watch, WatchError, WatchReceiver, WatchSender,
};
#[cfg(not(target_arch = "wasm32"))]
pub use moirai_async_macros::main;
#[cfg(all(test, not(target_arch = "wasm32")))]
mod tests {
use super::*;
#[test]
fn test_integration_async_executor() {
let executor = AsyncExecutor::new().expect("Failed to create executor");
let _handle = executor.spawn(async { "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();
}
}