pub struct SzEnvironmentCore {
is_destroyed: Arc<AtomicBool>,
is_initialized: Arc<AtomicBool>,
module_name: String,
ini_params: String,
verbose_logging: bool,
}
Expand description
Core implementation of the SzEnvironment trait
This struct manages the lifecycle of the Senzing environment and serves as a factory for obtaining instances of other SDK components.
Fields§
§is_destroyed: Arc<AtomicBool>
§is_initialized: Arc<AtomicBool>
§module_name: String
§ini_params: String
§verbose_logging: bool
Implementations§
Source§impl SzEnvironmentCore
impl SzEnvironmentCore
Sourcepub fn new(
module_name: &str,
ini_params: &str,
verbose_logging: bool,
) -> SzResult<Self>
pub fn new( module_name: &str, ini_params: &str, verbose_logging: bool, ) -> SzResult<Self>
Creates a new SzEnvironment instance
§Arguments
module_name
- Name of the module for logging purposesini_params
- JSON string containing initialization parametersverbose_logging
- Whether to enable verbose logging
Sourcepub fn new_default() -> SzResult<Self>
pub fn new_default() -> SzResult<Self>
Creates a new SzEnvironment instance with default parameters
Sourcepub fn get_instance(
module_name: &str,
ini_params: &str,
verbose_logging: bool,
) -> SzResult<Arc<Self>>
pub fn get_instance( module_name: &str, ini_params: &str, verbose_logging: bool, ) -> SzResult<Arc<Self>>
Gets or creates the global singleton SzEnvironmentCore instance
This method ensures that only one SzEnvironmentCore instance exists per process, which is required by the Senzing SDK.
§Arguments
module_name
- Name of the module for logging purposesini_params
- JSON string containing initialization parametersverbose_logging
- Whether to enable verbose logging
Sourcepub fn get_existing_instance() -> SzResult<Arc<Self>>
pub fn get_existing_instance() -> SzResult<Arc<Self>>
Gets the existing global singleton SzEnvironmentCore instance
This method returns the existing singleton instance without creating a new one. It will return an error if no instance has been created yet.
§Returns
Returns the existing singleton instance or an error if none exists.
Sourcepub fn try_get_instance() -> Option<Arc<Self>>
pub fn try_get_instance() -> Option<Arc<Self>>
Gets the global singleton instance if it exists
Returns None if no instance has been created yet.
Sourcepub fn destroy_global_instance() -> SzResult<()>
pub fn destroy_global_instance() -> SzResult<()>
Destroys the global singleton instance
This allows a new instance to be created with different parameters.
Sourcepub fn get_ini_params(&self) -> &str
pub fn get_ini_params(&self) -> &str
Get the initialization parameters used by this environment
Sourcepub fn get_verbose_logging(&self) -> bool
pub fn get_verbose_logging(&self) -> bool
Get the verbose logging setting used by this environment
Sourcefn ensure_initialized(&self) -> SzResult<()>
fn ensure_initialized(&self) -> SzResult<()>
Ensures Sz_init has been called - should be called before any engine operations
This method is thread-safe and will only call Sz_init once.