pub struct Runtime { /* private fields */ }Expand description
Runtime environment with automatic backend detection and fallback.
The runtime automatically detects the best available backend and provides information about the current environment for optimization guidance.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn auto_detect() -> Result<Self>
pub fn auto_detect() -> Result<Self>
Create a new runtime with automatic backend detection.
This method probes the system for io_uring availability and selects the best available backend. If io_uring is not available, it falls back to epoll (on Linux) or stub implementation (on other platforms).
§Returns
A runtime configured with the optimal backend for the current environment.
§Example
use safer_ring::runtime::Runtime;
let runtime = Runtime::auto_detect()?;
println!("Using backend: {}", runtime.backend().description());Sourcepub fn with_backend(backend: Backend) -> Result<Self>
pub fn with_backend(backend: Backend) -> Result<Self>
Create a runtime with a specific backend.
This bypasses automatic detection and forces the use of a specific backend. Use this when you want to test fallback behavior or have specific requirements.
§Arguments
backend- The backend to use
§Example
use safer_ring::runtime::{Runtime, Backend};
// Force epoll backend for testing
let runtime = Runtime::with_backend(Backend::Epoll)?;Sourcepub fn environment(&self) -> &EnvironmentInfo
pub fn environment(&self) -> &EnvironmentInfo
Get environment information.
Sourcepub fn is_cloud_environment(&self) -> bool
pub fn is_cloud_environment(&self) -> bool
Check if running in a cloud environment.
Sourcepub fn performance_guidance(&self) -> Vec<&'static str>
pub fn performance_guidance(&self) -> Vec<&'static str>
Get performance guidance for the current environment.