Skip to main content

Crate moirai_pal

Crate moirai_pal 

Source
Expand description

Platform Abstraction Layer (PAL) for Moirai async I/O operations.

This module provides platform-specific implementations of async I/O primitives that enable true non-blocking operations without external runtime dependencies.

§Architecture

The PAL provides a unified interface across platforms while leveraging optimal platform-specific async I/O mechanisms:

  • Linux: epoll-based event notification
  • macOS/BSD: kqueue-based event notification
  • Windows: WSAPoll-based socket readiness polling
  • WebAssembly: Web APIs with JavaScript interop

The Windows PAL can expose a thread-affine WebView2 host for packaged HTML/CSS/WebAssembly surfaces when the opt-in webview2 feature is enabled. Its URI, message and wait bounds are owned by the Rust provider; the installed WebView2 runtime remains a system prerequisite.

§Design Principles

  • Zero External Dependencies: Only platform system libraries
  • Zero-Copy Operations: Direct buffer management
  • Sub-microsecond Latency: Optimized for performance-critical applications
  • Memory Efficiency: Minimal per-operation overhead
  • Cross-Platform Consistency: Uniform behavior across all targets

Modules§

fs
Platform file-system primitives.
instance
Single-instance coordination between processes of one application.
net
Platform-agnostic async network I/O operations.
reactor
Central fd-readiness reactor over the platform backends.
thread
Errors from starting the runtime’s own helper threads.
timer
Platform-agnostic timer and timeout operations.
unix
Unix platform implementations for async I/O.

Structs§

Event
I/O event notification.
Interest
I/O event interest specification.

Traits§

Reactor
Platform-specific reactor interface.

Functions§

create_reactor
Platform-specific reactor factory.

Type Aliases§

PlatformReactor
Reactor implementation selected by the compile target.
RawFd
Platform-agnostic file descriptor/handle type.