1#![deny(missing_docs)]
10mod blocking;
14#[cfg(not(target_arch = "wasm32"))]
15pub mod executor;
16pub mod fs;
17pub mod io;
18#[cfg(any(unix, windows))]
19pub mod net;
20pub mod sync;
21pub mod timer;
22
23pub use io::{
25 AsyncBufRead, AsyncLength, AsyncMemReader, AsyncRead, AsyncReadAt, AsyncReadExt, AsyncWrite,
26 AsyncWriteExt, MoiraiCompat, TokioCompat,
27};
28
29#[cfg(not(target_arch = "wasm32"))]
31pub use executor::{AsyncExecutor, AsyncHandle, ExecutorStats};
32
33pub use timer::{
35 Delay, Interval, RateLimiter, RatePermit, Timeout, TimeoutError, TimerCommand, TimerWheel,
36 interval, interval_at, sleep, timeout,
37};
38
39#[cfg(any(unix, windows))]
41pub use net::{
42 ConnectionInfo, ConnectionPool, ConnectionStats, TcpListener, TcpServerConfig, TcpServerStats,
43 TcpStream, UdpConfig, UdpSocket, UdpSocketStats,
44};
45
46pub use fs::{
48 File, FileOpenOptions, FileStats, append, append_str, copy, create_dir, create_dir_all,
49 metadata, read, read_to_string, remove_dir, remove_dir_all, remove_file, rename, write,
50 write_str,
51};
52
53pub use sync::{
55 Broadcast, BroadcastError, BroadcastReceiver, BroadcastSender, Condvar, Mutex, MutexGuard,
56 Notify, RwLock, Semaphore, SemaphorePermit, Watch, WatchError, WatchReceiver, WatchSender,
57};
58
59#[cfg(not(target_arch = "wasm32"))]
62pub use moirai_async_macros::main;
63
64#[cfg(all(test, not(target_arch = "wasm32")))]
65mod tests {
66 use super::*;
67
68 #[test]
69 fn test_integration_async_executor() {
70 let executor = AsyncExecutor::new().expect("Failed to create executor");
71
72 let _handle = executor.spawn(async { "async task completed" });
73
74 let stats_before = executor.stats();
77 assert_eq!(stats_before.tasks_spawned, 1);
78 assert_eq!(stats_before.tasks_pending, 1);
79
80 }
83
84 #[test]
85 fn test_integration_executor_stats() {
86 let executor = AsyncExecutor::new().expect("Failed to create executor");
87
88 let stats = executor.stats();
89 assert_eq!(stats.tasks_spawned, 0);
90 assert_eq!(stats.tasks_completed, 0);
91 assert_eq!(stats.tasks_pending, 0);
92 assert_eq!(stats.io_operations, 0);
93 }
94
95 #[test]
96 fn test_integration_reactor_access() {
97 let executor = AsyncExecutor::new().expect("Failed to create executor");
98
99 let _reactor = executor.reactor();
101
102 }
104}