pub struct RuntimeConfig { /* private fields */ }Expand description
Runtime configuration manager
Provides thread-safe access to global runtime configuration. Configuration changes are immediately visible to all threads.
Implementations§
Source§impl RuntimeConfig
impl RuntimeConfig
Sourcepub fn global() -> Self
pub fn global() -> Self
Get the global runtime configuration instance
§Examples
use torsh_core::runtime_config::RuntimeConfig;
let config = RuntimeConfig::global();
println!("Debug level: {:?}", config.debug_level());Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new isolated runtime configuration (for testing)
§Examples
use torsh_core::runtime_config::RuntimeConfig;
let config = RuntimeConfig::new();
// This config is independent of the global configSourcepub fn debug_level(&self) -> DebugLevel
pub fn debug_level(&self) -> DebugLevel
Get the current debug level
Sourcepub fn set_debug_level(&self, level: DebugLevel)
pub fn set_debug_level(&self, level: DebugLevel)
Set the debug level
§Examples
use torsh_core::runtime_config::{RuntimeConfig, DebugLevel};
RuntimeConfig::global().set_debug_level(DebugLevel::Verbose);Sourcepub fn validation_level(&self) -> ValidationLevel
pub fn validation_level(&self) -> ValidationLevel
Get the current validation level
Sourcepub fn set_validation_level(&self, level: ValidationLevel)
pub fn set_validation_level(&self, level: ValidationLevel)
Set the validation level
§Examples
use torsh_core::runtime_config::{RuntimeConfig, ValidationLevel};
RuntimeConfig::global().set_validation_level(ValidationLevel::Maximum);Sourcepub fn monitoring_scope(&self) -> MonitoringScope
pub fn monitoring_scope(&self) -> MonitoringScope
Get the current monitoring scope
Sourcepub fn set_monitoring_scope(&self, scope: MonitoringScope)
pub fn set_monitoring_scope(&self, scope: MonitoringScope)
Set the monitoring scope
§Examples
use torsh_core::runtime_config::{RuntimeConfig, MonitoringScope};
RuntimeConfig::global().set_monitoring_scope(MonitoringScope::Comprehensive);Sourcepub fn memory_tracking(&self) -> MemoryTrackingConfig
pub fn memory_tracking(&self) -> MemoryTrackingConfig
Get memory tracking configuration
Sourcepub fn set_memory_tracking(&self, config: MemoryTrackingConfig)
pub fn set_memory_tracking(&self, config: MemoryTrackingConfig)
Set memory tracking configuration
Sourcepub fn set_log_level(&self, level: LogLevel)
pub fn set_log_level(&self, level: LogLevel)
Set the log level
§Examples
use torsh_core::runtime_config::RuntimeConfig;
use torsh_core::telemetry::LogLevel;
RuntimeConfig::global().set_log_level(LogLevel::Debug);Sourcepub fn is_testing(&self) -> bool
pub fn is_testing(&self) -> bool
Check if currently running in test mode
Sourcepub fn set_testing(&self, testing: bool)
pub fn set_testing(&self, testing: bool)
Set testing mode
Sourcepub fn panic_on_warnings(&self) -> bool
pub fn panic_on_warnings(&self) -> bool
Check if warnings should panic in debug mode
Sourcepub fn set_panic_on_warnings(&self, panic: bool)
pub fn set_panic_on_warnings(&self, panic: bool)
Set whether to panic on warnings in debug mode
Sourcepub fn get_operation_config(&self, operation: &str) -> Option<OperationConfig>
pub fn get_operation_config(&self, operation: &str) -> Option<OperationConfig>
Get configuration for a specific operation
§Examples
use torsh_core::runtime_config::RuntimeConfig;
let config = RuntimeConfig::global();
if let Some(op_config) = config.get_operation_config("matmul") {
println!("Matmul metrics enabled: {}", op_config.enable_metrics);
}Sourcepub fn set_operation_config(
&self,
operation: impl Into<String>,
config: OperationConfig,
)
pub fn set_operation_config( &self, operation: impl Into<String>, config: OperationConfig, )
Set configuration for a specific operation
§Examples
use torsh_core::runtime_config::{RuntimeConfig, OperationConfig};
let mut config = OperationConfig::default();
config.timeout_ms = Some(1000); // 1 second timeout
RuntimeConfig::global().set_operation_config("slow_operation", config);Sourcepub fn remove_operation_config(
&self,
operation: &str,
) -> Option<OperationConfig>
pub fn remove_operation_config( &self, operation: &str, ) -> Option<OperationConfig>
Remove configuration for a specific operation
Sourcepub fn clear_operation_configs(&self)
pub fn clear_operation_configs(&self)
Clear all operation-specific configurations
Sourcepub fn should_collect_metrics(&self, operation: &str) -> bool
pub fn should_collect_metrics(&self, operation: &str) -> bool
Check if an operation should collect metrics
Sourcepub fn should_validate(&self, operation: &str) -> bool
pub fn should_validate(&self, operation: &str) -> bool
Check if an operation should perform validation
Sourcepub fn should_validate_essential(&self) -> bool
pub fn should_validate_essential(&self) -> bool
Check if essential validation should be performed
Sourcepub fn should_validate_standard(&self) -> bool
pub fn should_validate_standard(&self) -> bool
Check if standard validation should be performed
Sourcepub fn should_validate_strict(&self) -> bool
pub fn should_validate_strict(&self) -> bool
Check if strict validation should be performed
Sourcepub fn should_validate_maximum(&self) -> bool
pub fn should_validate_maximum(&self) -> bool
Check if maximum validation should be performed
Sourcepub fn apply_preset(&self, preset: ConfigPreset)
pub fn apply_preset(&self, preset: ConfigPreset)
Apply a preset configuration for specific environments
§Examples
use torsh_core::runtime_config::{RuntimeConfig, ConfigPreset};
// Development mode
RuntimeConfig::global().apply_preset(ConfigPreset::Development);
// Production mode
RuntimeConfig::global().apply_preset(ConfigPreset::Production);Sourcepub fn snapshot(&self) -> RuntimeConfigSnapshot
pub fn snapshot(&self) -> RuntimeConfigSnapshot
Get a snapshot of the current configuration (for debugging)
Trait Implementations§
Source§impl Clone for RuntimeConfig
impl Clone for RuntimeConfig
Source§fn clone(&self) -> RuntimeConfig
fn clone(&self) -> RuntimeConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RuntimeConfig
impl RefUnwindSafe for RuntimeConfig
impl Send for RuntimeConfig
impl Sync for RuntimeConfig
impl Unpin for RuntimeConfig
impl UnsafeUnpin for RuntimeConfig
impl UnwindSafe for RuntimeConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more