windows_registry

Struct Key

source
pub struct Key(/* private fields */);
Expand description

A registry key.

Implementations§

source§

impl Key

source

pub fn create<T: AsRef<str>>(&self, path: T) -> Result<Self>

Creates a registry key. If the key already exists, the function opens it.

source

pub fn open<T: AsRef<str>>(&self, path: T) -> Result<Self>

Opens a registry key.

source

pub unsafe fn from_raw(handle: *mut c_void) -> Self

Constructs a registry key from an existing handle.

§Safety

This function takes ownership of the handle. The handle must be owned by the caller and safe to free with RegCloseKey.

source

pub fn as_raw(&self) -> *mut c_void

Returns the underlying registry key handle.

source

pub fn remove_tree<T: AsRef<str>>(&self, path: T) -> Result<()>

Removes the registry keys and values of the specified key recursively.

source

pub fn remove_value<T: AsRef<str>>(&self, name: T) -> Result<()>

Removes the registry value.

source

pub fn keys(&self) -> Result<KeyIterator<'_>>

Creates an iterator of registry key names.

source

pub fn values(&self) -> Result<ValueIterator<'_>>

Creates an iterator of registry values.

source

pub fn set_u32<T: AsRef<str>>(&self, name: T, value: u32) -> Result<()>

Sets the name and value in the registry key.

source

pub fn set_u64<T: AsRef<str>>(&self, name: T, value: u64) -> Result<()>

Sets the name and value in the registry key.

source

pub fn set_string<T: AsRef<str>>(&self, name: T, value: T) -> Result<()>

Sets the name and value in the registry key.

source

pub fn set_hstring<T: AsRef<str>>(&self, name: T, value: &HSTRING) -> Result<()>

Sets the name and value in the registry key.

source

pub fn set_expand_string<T: AsRef<str>>(&self, name: T, value: T) -> Result<()>

Sets the name and value in the registry key.

source

pub fn set_expand_hstring<T: AsRef<str>>( &self, name: T, value: &HSTRING, ) -> Result<()>

Sets the name and value in the registry key.

source

pub fn set_multi_string<T: AsRef<str>>( &self, name: T, value: &[T], ) -> Result<()>

Sets the name and value in the registry key.

source

pub fn set_value<T: AsRef<str>>(&self, name: T, value: &Value) -> Result<()>

Sets the name and value in the registry key.

source

pub fn set_bytes<T: AsRef<str>>( &self, name: T, ty: Type, value: &[u8], ) -> Result<()>

Sets the name and value in the registry key.

source

pub fn get_type<T: AsRef<str>>(&self, name: T) -> Result<Type>

Gets the type for the name in the registry key.

source

pub fn get_value<T: AsRef<str>>(&self, name: T) -> Result<Value>

Gets the value for the name in the registry key.

source

pub fn get_u32<T: AsRef<str>>(&self, name: T) -> Result<u32>

Gets the value for the name in the registry key.

source

pub fn get_u64<T: AsRef<str>>(&self, name: T) -> Result<u64>

Gets the value for the name in the registry key.

source

pub fn get_string<T: AsRef<str>>(&self, name: T) -> Result<String>

Gets the value for the name in the registry key.

source

pub fn get_hstring<T: AsRef<str>>(&self, name: T) -> Result<HSTRING>

Gets the value for the name in the registry key.

source

pub fn get_multi_string<T: AsRef<str>>(&self, name: T) -> Result<Vec<String>>

Gets the value for the name in the registry key.

source

pub unsafe fn raw_set_bytes<N: AsRef<PCWSTR>>( &self, name: N, ty: Type, value: &[u8], ) -> Result<()>

Sets the name and value in the registry key.

This method avoids any allocations.

§Safety

The PCWSTR pointer needs to be valid for reads up until and including the next \0.

source

pub unsafe fn raw_get_info<N: AsRef<PCWSTR>>( &self, name: N, ) -> Result<(Type, usize)>

Gets the type and length for the name in the registry key.

This method avoids any allocations.

§Safety

The PCWSTR pointer needs to be valid for reads up until and including the next \0.

source

pub unsafe fn raw_get_bytes<'a, N: AsRef<PCWSTR>>( &self, name: N, value: &'a mut [u8], ) -> Result<(Type, &'a [u8])>

Gets the value for the name in the registry key.

This method avoids any allocations.

§Safety

The PCWSTR pointer needs to be valid for reads up until and including the next \0.

Trait Implementations§

source§

impl Debug for Key

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Key

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Drop for Key

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Key

§

impl RefUnwindSafe for Key

§

impl !Send for Key

§

impl !Sync for Key

§

impl Unpin for Key

§

impl UnwindSafe for Key

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