pub trait ContextGlobalPropertiesExt: ContextBase {
// Required methods
fn get_serialized_value_by_string(
&self,
name: &str,
) -> Result<Option<String>, IxaError>;
fn load_global_properties(
&mut self,
file_name: &Path,
) -> Result<(), IxaError>;
// Provided methods
fn set_global_property_value<T: GlobalProperty + 'static>(
&mut self,
property: T,
value: T::Value,
) -> Result<(), IxaError> { ... }
fn get_global_property_value<T: GlobalProperty + 'static>(
&self,
_property: T,
) -> Option<&T::Value> { ... }
fn list_registered_global_properties(&self) -> Vec<String> { ... }
fn load_parameters_from_json<T: 'static + Debug + DeserializeOwned>(
&mut self,
file_name: &Path,
) -> Result<T, IxaError> { ... }
}Required Methods§
Sourcefn load_global_properties(&mut self, file_name: &Path) -> Result<(), IxaError>
fn load_global_properties(&mut self, file_name: &Path) -> Result<(), IxaError>
Load global properties from a JSON file.
The expected structure is a dictionary with each name being
the name of the struct prefixed with the crate name, as in:
ixa.NumFluVariants and the value being an object which can
serde deserialize into the relevant struct.
§Errors
Will return an IxaError if:
- The
file_pathdoesn’t exist - The file isn’t valid JSON
- A specified object doesn’t correspond to an existing global property.
- There are two values for the same object.
Ixa automatically knows about any property defined with
define_global_property! so you don’t need to register them
explicitly.
It is possible to call Context::load_global_properties() multiple
times with different files as long as the files have disjoint
sets of properties.
Provided Methods§
Sourcefn set_global_property_value<T: GlobalProperty + 'static>(
&mut self,
property: T,
value: T::Value,
) -> Result<(), IxaError>
fn set_global_property_value<T: GlobalProperty + 'static>( &mut self, property: T, value: T::Value, ) -> Result<(), IxaError>
Set the value of a global property of type T
§Errors
Will return an error if an attempt is made to change a value.
Sourcefn get_global_property_value<T: GlobalProperty + 'static>(
&self,
_property: T,
) -> Option<&T::Value>
fn get_global_property_value<T: GlobalProperty + 'static>( &self, _property: T, ) -> Option<&T::Value>
Return value of global property T
fn list_registered_global_properties(&self) -> Vec<String>
Sourcefn load_parameters_from_json<T: 'static + Debug + DeserializeOwned>(
&mut self,
file_name: &Path,
) -> Result<T, IxaError>
fn load_parameters_from_json<T: 'static + Debug + DeserializeOwned>( &mut self, file_name: &Path, ) -> Result<T, IxaError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.