SzEnvironment

Trait SzEnvironment 

Source
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§

Source

fn is_destroyed(&self) -> bool

Checks if the environment has been destroyed.

§Returns

true if destroy() has been called, false otherwise.

§Examples
use sz_rust_sdk::prelude::*;

let destroyed = env.is_destroyed();
assert!(!destroyed);
Source

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 exist
  • SzError::EnvironmentDestroyed - Environment was destroyed
Source

fn get_active_config_id(&self) -> SzResult<ConfigId>

Gets the currently active configuration ID.

§Returns

The configuration ID currently in use by the engine.

§Examples
use sz_rust_sdk::prelude::*;

let config_id = env.get_active_config_id()?;
println!("Active config ID: {}", config_id);
§Errors
  • SzError::EnvironmentDestroyed - Environment was destroyed
Source

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
Source

fn get_engine(&self) -> SzResult<Box<dyn SzEngine>>

Gets the engine interface for entity resolution operations.

§Returns

An SzEngine instance for adding records, searching, and analysis.

§Examples
use sz_rust_sdk::prelude::*;

let engine = env.get_engine()?;
§Errors
  • SzError::EnvironmentDestroyed - Environment was destroyed
Source

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
Source

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

Implementors§