Trait CapeRegistryKeyReader

Source
pub trait CapeRegistryKeyReader: CapeRegistryKeyReaderKey {
    // Provided methods
    fn get_values(&self) -> Result<Vec<String>, COBIAError> { ... }
    fn get_keys(&self) -> Result<Vec<String>, COBIAError> { ... }
    fn get_value_type(
        &self,
        value_name: &str,
        sub_key: Option<&str>,
    ) -> Result<CapeRegistryValueType, COBIAError> { ... }
    fn get_string_value(
        &self,
        value_name: &str,
        sub_key: Option<&str>,
    ) -> Result<String, COBIAError> { ... }
    fn get_integer_value(
        &self,
        value_name: &str,
        sub_key: Option<&str>,
    ) -> Result<i32, COBIAError> { ... }
    fn get_uuid_value(
        &self,
        value_name: &str,
        sub_key: Option<&str>,
    ) -> Result<CapeUUID, COBIAError> { ... }
    fn get_sub_key(&self, key_name: &str) -> Result<CapeRegistryKey, COBIAError> { ... }
    fn is_all_users(&self, value_name: &str) -> Result<bool, COBIAError> { ... }
}
Expand description

Public trait that provides methods to read from the registry key

This trait provides methods to read values from the registry key. This is implemented by CapeRegistryKey as well as CapeRegistryKeyWriter.

§Example

use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let lib_key=cobia::CapeRegistryKey::from_path("/types/libraries/{8d1d724f-ab15-48e5-80e4-a612468e68d4}").unwrap(); //points to the CAPE-OPEN 1.2 type library
assert_eq!(lib_key.get_string_value("name",None).unwrap(), "CAPEOPEN_1_2".to_string()); //check its name
cobia::cape_open_cleanup();

Provided Methods§

Source

fn get_values(&self) -> Result<Vec<String>, COBIAError>

Get a list of all values names in the key

This method returns a list of all value names in the key. The values can be of different types: string, integer, UUID or empty.

§Example
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let lib_key=cobia::CapeRegistryKey::from_path("/types/libraries/{8d1d724f-ab15-48e5-80e4-a612468e68d4}").unwrap(); //points to the CAPE-OPEN 1.2 type library
assert!(lib_key.get_values().unwrap().contains(&("name".to_string()))); //see that 'name' is amongst them
cobia::cape_open_cleanup();
Source

fn get_keys(&self) -> Result<Vec<String>, COBIAError>

Get a list of all sub key names in the key

This method returns a list of all sub key names in the key.

§Example
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let lib_key=cobia::CapeRegistryKey::from_path("/types").unwrap(); //points to the CAPE-OPEN 1.2 type library
let keys=lib_key.get_keys().unwrap();
assert!(keys.contains(&("categories".to_string()))); //see that 'categories' is amongst them
assert!(keys.contains(&("interfaces".to_string()))); //see that 'interfaces' is amongst them
assert!(keys.contains(&("enumerations".to_string()))); //see that 'enumerations' is amongst them
assert!(keys.contains(&("libraries".to_string()))); //see that 'libraries' is amongst them
cobia::cape_open_cleanup();
Source

fn get_value_type( &self, value_name: &str, sub_key: Option<&str>, ) -> Result<CapeRegistryValueType, COBIAError>

Get the type of a value

This method returns the type of a value in the key. The value can be of different types, such as string, integer, or UUID.

§Example
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let lib_key=cobia::CapeRegistryKey::from_path("/types/libraries/{8d1d724f-ab15-48e5-80e4-a612468e68d4}").unwrap(); //points to the CAPE-OPEN 1.2 type library
assert_eq!(lib_key.get_value_type("name",None).unwrap(), cobia::CapeRegistryValueType::String); //check that 'name' is a string
cobia::cape_open_cleanup();
Source

fn get_string_value( &self, value_name: &str, sub_key: Option<&str>, ) -> Result<String, COBIAError>

Get a string value

This method returns a string value from the key.

§Arguments
  • value_name - The name of the value to get
  • sub_key - The name of the sub key to get the value from. If None, the value is taken from the key itself.
§Example
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let lib_key=cobia::CapeRegistryKey::from_path("/types/interfaces/{12ebf184-f47a-4407-b52a-7fcc0a70451c}").unwrap(); //points to the CAPE-OPEN 1.2 ICapeIdentification interface
assert_eq!(lib_key.get_string_value("name",None).unwrap(), "ICapeIdentification".to_string()); //check its name
cobia::cape_open_cleanup();

Or, equivalently,

use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let lib_key=cobia::CapeRegistryKey::from_path("/types").unwrap(); //points to the types key
assert_eq!(lib_key.get_string_value("name",Some("interfaces/{12ebf184-f47a-4407-b52a-7fcc0a70451c}")).unwrap(), "ICapeIdentification".to_string()); //check name of ICapeIdentification interface
cobia::cape_open_cleanup();

This will not work, as the vlaue is not a string

use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let lib_key=cobia::CapeRegistryKey::from_path("/types/interfaces/{}").unwrap(); //points to the CAPE-OPEN 1.2 type library
assert_eq!(lib_key.get_string_value("version",None).unwrap(), "1.2".to_string()); //check its version
let str=lib_key.get_string_value("library",None).unwrap(); //fails, this is a uuid
cobia::cape_open_cleanup();
Source

fn get_integer_value( &self, value_name: &str, sub_key: Option<&str>, ) -> Result<i32, COBIAError>

Get an integer value

This method returns an integer value from the key.

§Arguments
  • value_name - The name of the value to get
  • sub_key - The name of the sub key to get the value from. If None, the value is taken from the key itself.
§Example
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let lib_key=cobia::CapeRegistryKey::from_path("/types/interfaces/{b135a443-2ed8-45ef-bb2d-e68d2e631c31}").unwrap(); //points to the CAPE-OPEN 1.2 ICapeCollection interface
assert_eq!(lib_key.get_integer_value("numberOfTemplateArguments",None).unwrap(), 1); //check number of template arguments
cobia::cape_open_cleanup();

Or, equivalently,

use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let lib_key=cobia::CapeRegistryKey::from_path("/types/interfaces").unwrap(); //points to the interfaces key
assert_eq!(lib_key.get_integer_value("numberOfTemplateArguments",Some("{b135a443-2ed8-45ef-bb2d-e68d2e631c31}")).unwrap(), 1); //check number of template arguments of ICapeCollection interface
cobia::cape_open_cleanup();
Source

fn get_uuid_value( &self, value_name: &str, sub_key: Option<&str>, ) -> Result<CapeUUID, COBIAError>

Get a UUID value

This method returns a UUID value from the key.

§Arguments
  • value_name - The name of the value to get
  • sub_key - The name of the sub key to get the value from. If None, the value is taken from the key itself.
§Example
use cobia;
use cobia::cape_open_1_2;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let lib_key=cobia::CapeRegistryKey::from_path("/types/interfaces/{12ebf184-f47a-4407-b52a-7fcc0a70451c}").unwrap(); //points to the CAPE-OPEN 1.2 ICapeIdentification interface
assert_eq!(lib_key.get_uuid_value("library",None).unwrap(), cobia::cape_open_1_2::LIBRARY_ID); //check library id
cobia::cape_open_cleanup();
Source

fn get_sub_key(&self, key_name: &str) -> Result<CapeRegistryKey, COBIAError>

Get a sub key

This method returns a sub key from the key.

§Arguments
  • key_name - The name of the sub key to get
§Example
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let lib_key=cobia::CapeRegistryKey::from_path("/types/interfaces").unwrap(); //points to the interfaces key
let icape_collection_key=lib_key.get_sub_key("{b135a443-2ed8-45ef-bb2d-e68d2e631c31}").unwrap(); //points to the ICapeCollection interface
assert_eq!(icape_collection_key.get_string_value("name",None).unwrap(), "ICapeCollection".to_string()); //check its name
cobia::cape_open_cleanup();
Source

fn is_all_users(&self, value_name: &str) -> Result<bool, COBIAError>

Check whether a particular value is in the registry for all users or just the current user

This method checks whether a particular value is in the registry for all users or just the current user.

§Arguments
  • value_name - The name of the value to check
§Example
use cobia;
use cobia::prelude::*;
cobia::cape_open_initialize().unwrap();
let lib_key=cobia::CapeRegistryKey::from_path("/types/interfaces/{12ebf184-f47a-4407-b52a-7fcc0a70451c}").unwrap(); //points to the CAPE-OPEN 1.2 ICapeIdentification interface
println!("The name for  CAPE-OPEN 1.2 ICapeIdentification is in the {} part of the registry", 
            if lib_key.is_all_users("name").unwrap() {"all users"} else {"current user"} ); 
cobia::cape_open_cleanup();

Implementors§