pub trait SzEnvironment: Send + Sync {
// Required methods
fn is_destroyed(&self) -> bool;
fn reinitialize(&self, config_id: ConfigId) -> SzResult<()>;
fn get_active_config_id(&self) -> SzResult<ConfigId>;
fn get_product(&self) -> SzResult<Box<dyn SzProduct>>;
fn get_engine(&self) -> SzResult<Box<dyn SzEngine>>;
fn get_config_manager(&self) -> SzResult<Box<dyn SzConfigManager>>;
fn get_diagnostic(&self) -> SzResult<Box<dyn SzDiagnostic>>;
}Expand description
Main entry point and factory for Senzing SDK components.
The SzEnvironment trait provides the primary interface for initializing
the Senzing SDK and obtaining instances of other SDK components. This is
the first interface you interact with when using the SDK.
§Example
use sz_rust_sdk::prelude::*;
// Get component interfaces
let engine = env.get_engine()?;
let product = env.get_product()?;§Singleton Pattern
SzEnvironmentCore implements a singleton pattern. Multiple calls to
get_instance with the same parameters return the same instance.
Required Methods§
Sourcefn is_destroyed(&self) -> bool
fn is_destroyed(&self) -> bool
Sourcefn reinitialize(&self, config_id: ConfigId) -> SzResult<()>
fn reinitialize(&self, config_id: ConfigId) -> SzResult<()>
Reinitializes the environment with a different configuration.
Switches to a different registered configuration without destroying the environment. This is thread-safe and can be called while other operations are in progress.
§Arguments
config_id- ID of a registered configuration to activate
§Examples
use sz_rust_sdk::prelude::*;
let config_id = env.get_active_config_id()?;
env.reinitialize(config_id)?;§Errors
SzError::NotFound- Configuration ID does not existSzError::EnvironmentDestroyed- Environment was destroyed
Sourcefn get_active_config_id(&self) -> SzResult<ConfigId>
fn get_active_config_id(&self) -> SzResult<ConfigId>
Sourcefn get_product(&self) -> SzResult<Box<dyn SzProduct>>
fn get_product(&self) -> SzResult<Box<dyn SzProduct>>
Gets the product interface for version and license information.
§Returns
An SzProduct instance for querying product information.
§Examples
use sz_rust_sdk::prelude::*;
let product = env.get_product()?;
let version = product.get_version()?;
println!("Senzing version: {}", version);§Errors
SzError::EnvironmentDestroyed- Environment was destroyed
Sourcefn get_engine(&self) -> SzResult<Box<dyn SzEngine>>
fn get_engine(&self) -> SzResult<Box<dyn SzEngine>>
Sourcefn get_config_manager(&self) -> SzResult<Box<dyn SzConfigManager>>
fn get_config_manager(&self) -> SzResult<Box<dyn SzConfigManager>>
Gets the configuration manager interface.
§Returns
An SzConfigManager instance for managing configuration versions.
§Examples
use sz_rust_sdk::prelude::*;
let config_mgr = env.get_config_manager()?;§Errors
SzError::EnvironmentDestroyed- Environment was destroyed
Sourcefn get_diagnostic(&self) -> SzResult<Box<dyn SzDiagnostic>>
fn get_diagnostic(&self) -> SzResult<Box<dyn SzDiagnostic>>
Gets the diagnostic interface for system monitoring.
§Returns
An SzDiagnostic instance for performance testing and repository info.
§Examples
use sz_rust_sdk::prelude::*;
let diagnostic = env.get_diagnostic()?;§Errors
SzError::EnvironmentDestroyed- Environment was destroyed