Struct CapeRegistryWriter

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

Implementations§

Source§

impl CapeRegistryWriter

Source

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();
Source

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();
Source

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();
Source

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();
Source

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();
Source

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.

Source

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.

Source

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.

Source

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();
Source

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();
Source

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

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

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

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

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

ICapeRegistryWriter derives from ICobiaBase, which contains addReference() and release(). The Clone trait calls addReference.

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for CapeRegistryWriter

Release pointer

ICapeRegistryWriter derives from ICobiaBase, which contains addReference() and release(). The Drop trait calls release.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.