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 + Syncrequired (multi-threaded tokio runtime). - Browser:
?Send(single-threaded WASM runtime).
Required Methods§
Sourcefn http(&self) -> &dyn HttpClient
fn http(&self) -> &dyn HttpClient
HTTP client for making API requests.
Sourcefn fs(&self) -> &dyn FileSystem
fn fs(&self) -> &dyn FileSystem
Filesystem operations.
Sourcefn env(&self) -> &dyn Environment
fn env(&self) -> &dyn Environment
Environment variable access.
Sourcefn process(&self) -> Option<&dyn ProcessSpawner>
fn process(&self) -> Option<&dyn ProcessSpawner>
Process spawning capability.
Returns None in environments where process spawning is unavailable
(e.g., WASM).