pub struct CapeRegistryWriter {
interface: *mut ICapeRegistryWriter,
}Expand description
Opens the COBIA registry for writing
This struct is used to write to the COBIA registry. To write values in the registry one obtains a sub-key using create_key, which is created if it does not already exist.
Values are not written to the registry until commit() is called.
§Example
use cobia::*;
cobia::cape_open_initialize().unwrap();
let writer = CapeRegistryWriter::new(false).unwrap();
cobia::cape_open_cleanup();Fields§
§interface: *mut ICapeRegistryWriterImplementations§
Source§impl CapeRegistryWriter
impl CapeRegistryWriter
Sourcepub fn new(all_users: bool) -> Result<CapeRegistryWriter, COBIAError>
pub fn new(all_users: bool) -> Result<CapeRegistryWriter, COBIAError>
Opens the COBIA registry for writing
This function opens the COBIA registry for writing. If all_users is true the registry is opened for all users, otherwise it is opened for the current user.
Opening the registry for writing to the all-users hive typically requires administrative privileges.
§Arguments
all_users- If true the registry is opened for all users, otherwise it is opened for the current user.
§Returns
A CapeRegistryWriter object if successful, otherwise a COBIAError.
§Example
use cobia::*;
cobia::cape_open_initialize().unwrap();
let writer = CapeRegistryWriter::new(false).unwrap();
cobia::cape_open_cleanup();Sourcepub fn create_key(
&self,
key_name: &str,
) -> Result<CapeRegistryKeyWriter<'_>, COBIAError>
pub fn create_key( &self, key_name: &str, ) -> Result<CapeRegistryKeyWriter<'_>, COBIAError>
Creates or opens key in the registry
This function creates or opens a key in the registry. If the key does not exist it is created.
§Arguments
key_name- The name of the key to create or open. Must be an absolute path, starting with a forward slash.
§Returns
A CapeRegistryKeyWriter object if successful, otherwise a COBIAError.
§Example
use cobia::*;
cobia::cape_open_initialize().unwrap();
let writer = CapeRegistryWriter::new(false).unwrap();
let key=writer.create_key("/cobia_rust_create_key").unwrap();
//note the key does not actually appear in the registry at this point, as we did
//not call commit().
cobia::cape_open_cleanup();Sourcepub fn get_key(&self, key_name: &str) -> Result<CapeRegistryKey, COBIAError>
pub fn get_key(&self, key_name: &str) -> Result<CapeRegistryKey, COBIAError>
Opens key in the registry for reading.
This function returns a read-only key; for a writable key, use create_key instead.
This function opens an existing key in the registry. If the key does not exist it fails.
§Arguments
key_name- The name of the key to open. Must be an absolute path, starting with a forward slash.
§Returns
A CapeRegistryKeyWriter object if successful, otherwise a COBIAError.
§Example
use cobia::*;
cobia::cape_open_initialize().unwrap();
let writer = CapeRegistryWriter::new(false).unwrap();
let key=writer.get_key("/types").unwrap();
cobia::cape_open_cleanup();Sourcepub fn delete_key(&self, key_name: &str) -> Result<(), COBIAError>
pub fn delete_key(&self, key_name: &str) -> Result<(), COBIAError>
Deletes key in the registry
This function deletes a key in the registry. If the key does not exist it succeeds. Changes to do not take effect until commit() is called.
§Arguments
key_name- The name of the key to delete. Must be an absolute path, starting with a forward slash.
§Example
use cobia::*;
cobia::cape_open_initialize().unwrap();
//first create a sub key for the current user
{
let writer = CapeRegistryWriter::new(false).unwrap();
writer.create_key("/cobia_rust_delete_key").unwrap();
writer.commit().unwrap();
}
//now delete the key for the current user
let writer = CapeRegistryWriter::new(false).unwrap();
writer.delete_key("/cobia_rust_delete_key").unwrap();
writer.commit().unwrap();
cobia::cape_open_cleanup();This will succeed, as the key does not exist:
use cobia::*;
cobia::cape_open_initialize().unwrap();
let writer = CapeRegistryWriter::new(false).unwrap();
writer.delete_key("/key_that_does_not_exist").unwrap();
cobia::cape_open_cleanup();Sourcepub fn delete_value(
&self,
key_name: &str,
value_name: &str,
) -> Result<(), COBIAError>
pub fn delete_value( &self, key_name: &str, value_name: &str, ) -> Result<(), COBIAError>
Deletes a value in the registry
This function deletes a value in the registry. If the value does not exist it fails. Changes to do not take effect until commit() is called.
§Arguments
key_name- The name of the key containing the value. Must be an absolute path, starting with a forward slash.value_name- The name of the value to delete.
use cobia::*;
cobia::cape_open_initialize().unwrap();
//first create a sub key for the current user
{
let writer = CapeRegistryWriter::new(false).unwrap();
writer.create_key("/cobia_rust_delete_value").unwrap().
set_string_value("test_value", "test_value").unwrap();
writer.commit().unwrap();
}
//now delete the value for the current user
let writer = CapeRegistryWriter::new(false).unwrap();
writer.delete_value("/cobia_rust_delete_value","test_value").unwrap();
writer.commit().unwrap();
cobia::cape_open_cleanup();Sourcepub fn get_pmc_registrar(&self) -> Result<CapeRegistrar, COBIAError>
pub fn get_pmc_registrar(&self) -> Result<CapeRegistrar, COBIAError>
Get a registrar object
Registrar object facilitate the registration of PMCs.
This function is not typically called directly; it is used in the self-registation entry point, which is typically generated using the pmc_entry_points! macro.
Sourcepub fn unregister_pmc(&self, uuid: &CapeUUID) -> Result<(), COBIAError>
pub fn unregister_pmc(&self, uuid: &CapeUUID) -> Result<(), COBIAError>
Unregister a PMC by uuid.
This function unregisters a PMC by uuid. Changes to do not take effect until commit() is called.
This function is not typically called directly; it is used in the self-unregistation entry point, which is typically generated using the pmc_entry_points! macro.
Sourcepub fn unregister_pmc_service(
&self,
uuid: &CapeUUID,
service: CapePMCServiceType,
) -> Result<(), COBIAError>
pub fn unregister_pmc_service( &self, uuid: &CapeUUID, service: CapePMCServiceType, ) -> Result<(), COBIAError>
Unregister a service for a PMC by uuid.
This function unregisters service for a PMC by uuid. Changes to do not take effect until commit() is called.
This function is not typically called directly; it is used in the self-unregistation entry point, which is typically generated using the pmc_entry_points! macro.
Sourcepub fn commit(&self) -> Result<(), COBIAError>
pub fn commit(&self) -> Result<(), COBIAError>
Commit changes to the registry
This function commits changes to the registry. Changes are not written to the registry until this function is called.
§Example
use cobia::*;
cobia::cape_open_initialize().unwrap();
let writer = CapeRegistryWriter::new(false).unwrap();
writer.create_key("/cobia_rust_commit").unwrap().
set_string_value("test_value", "test_value").unwrap();
writer.commit().unwrap();
//now the key and value are in the registry
let key=writer.get_key("/cobia_rust_commit").unwrap();
let value=key.get_string_value("test_value",None).unwrap();
assert_eq!(value,"test_value");
//delete the key
let writer = CapeRegistryWriter::new(false).unwrap();
writer.delete_key("/cobia_rust_commit").unwrap();
writer.commit().unwrap();
cobia::cape_open_cleanup();Sourcepub fn revert(&self) -> Result<(), COBIAError>
pub fn revert(&self) -> Result<(), COBIAError>
Revert changes to the registry
This function ignores all changes made to the registry since the last commit without committing them.
§Example
use cobia::*;
cobia::cape_open_initialize().unwrap();
let writer = CapeRegistryWriter::new(false).unwrap();
writer.create_key("/rust_cobia_test_key").unwrap().
set_string_value("test_value", "test_value").unwrap();
writer.revert().unwrap();
//start over
writer.create_key("/rust_cobia_test_key").unwrap().
set_string_value("test_value", "1-2-3-test").unwrap();
cobia::cape_open_cleanup();Sourcepub fn register_types_from_idl<T: AsRef<str>>(
&self,
idl_files: &[T],
) -> Result<(), COBIAError>
pub fn register_types_from_idl<T: AsRef<str>>( &self, idl_files: &[T], ) -> Result<(), COBIAError>
Register types from IDL
This function registers types from IDL files. This function is not typically called. It is called for example by the cobiaRegister registration tool.
§Arguments
idl_files- A vector of strings containing the paths to the IDL files.
Sourcepub fn register_types_from_idl_paths(
&self,
idl_files: &[&Path],
) -> Result<(), COBIAError>
pub fn register_types_from_idl_paths( &self, idl_files: &[&Path], ) -> Result<(), COBIAError>
Register types from IDL
This function registers types from IDL files. This function is not typically called. It is called for example by the cobiaRegister registration tool.
§Arguments
idl_files- A vector of Paths to the IDL files.
Sourcepub fn unregister_types(&self, library_id: &CapeUUID) -> Result<(), COBIAError>
pub fn unregister_types(&self, library_id: &CapeUUID) -> Result<(), COBIAError>
Unregister types from IDL
This function unregisters types from IDL files by library ID. This function is not typically called. It is called for example by the cobiaRegister registration tool.
§Arguments
library_id- The library ID of the types to unregister.
Sourcepub fn register_proxy_interface_provider(
&self,
library_id: &CapeUUID,
service_type: CapePMCServiceType,
location: &str,
) -> Result<(), COBIAError>
pub fn register_proxy_interface_provider( &self, library_id: &CapeUUID, service_type: CapePMCServiceType, location: &str, ) -> Result<(), COBIAError>
Register proxy interface provider
This function registers a proxy interface provider. This function is not typically called. It is called for example by the cobiaRegister registration tool.
§Arguments
library_id- The library ID of the proxy interface provider.service_type- The service type of the proxy interface provider.location- The location of the proxy interface provider, typically a path to a shared library.
Sourcepub fn unregister_proxy_interface_provider(
&self,
library_id: &CapeUUID,
service_type: CapePMCServiceType,
) -> Result<(), COBIAError>
pub fn unregister_proxy_interface_provider( &self, library_id: &CapeUUID, service_type: CapePMCServiceType, ) -> Result<(), COBIAError>
Unregister proxy interface provider
This function unregisters a proxy interface provider. This function is not typically called. It is called for example by the cobiaRegister registration tool.
§Arguments
library_id- The library ID of the proxy interface provider.service_type- The service type of the proxy interface provider.
Trait Implementations§
Source§impl Clone for CapeRegistryWriter
Add pointer reference
impl Clone for CapeRegistryWriter
Add pointer reference
ICapeRegistryWriter derives from ICobiaBase, which contains addReference() and release(). The Clone trait calls addReference.