Skip to main content

Platform

Trait Platform 

Source
pub trait Platform: Send + Sync {
    // Required methods
    fn http(&self) -> &dyn HttpClient;
    fn fs(&self) -> &dyn FileSystem;
    fn env(&self) -> &dyn Environment;
    fn process(&self) -> Option<&dyn ProcessSpawner>;
}
Expand description

Bundle of all platform capabilities.

Implementors provide concrete implementations of all platform traits. The native implementation (NativePlatform) uses reqwest, tokio::fs, std::env, and tokio::process. A WASM implementation would use the fetch API, WASI filesystem, and an in-memory environment.

The async_trait bound differs based on target:

  • Native: Send + Sync required (multi-threaded tokio runtime).
  • Browser: ?Send (single-threaded WASM runtime).

Required Methods§

Source

fn http(&self) -> &dyn HttpClient

HTTP client for making API requests.

Source

fn fs(&self) -> &dyn FileSystem

Filesystem operations.

Source

fn env(&self) -> &dyn Environment

Environment variable access.

Source

fn process(&self) -> Option<&dyn ProcessSpawner>

Process spawning capability.

Returns None in environments where process spawning is unavailable (e.g., WASM).

Implementors§