From 3fd5bc4182feb771bb920e11d4a766a81d9f0145 Mon Sep 17 00:00:00 2001 From: Rodrigo Cesar de Freitas Dias Date: Fri, 14 Feb 2025 18:49:33 -0300 Subject: [PATCH] Cargo doc auto deployment 2025-02-14 18:49:33. --- src/winsafe/advapi/handles/hkey.rs.html | 268 +++++------------------- winsafe/prelude/trait.advapi_Hkey.html | 113 ++-------- winsafe/struct.HKEY.html | 34 +-- 3 files changed, 89 insertions(+), 326 deletions(-) diff --git a/src/winsafe/advapi/handles/hkey.rs.html b/src/winsafe/advapi/handles/hkey.rs.html index 4cd42abe7e..b52ce02263 100644 --- a/src/winsafe/advapi/handles/hkey.rs.html +++ b/src/winsafe/advapi/handles/hkey.rs.html @@ -946,90 +946,7 @@ 945 946 947 -948 -949 -950 -951 -952 -953 -954 -955 -956 -957 -958 -959 -960 -961 -962 -963 -964 -965 -966 -967 -968 -969 -970 -971 -972 -973 -974 -975 -976 -977 -978 -979 -980 -981 -982 -983 -984 -985 -986 -987 -988 -989 -990 -991 -992 -993 -994 -995 -996 -997 -998 -999 -1000 -1001 -1002 -1003 -1004 -1005 -1006 -1007 -1008 -1009 -1010 -1011 -1012 -1013 -1014 -1015 -1016 -1017 -1018 -1019 -1020 -1021 -1022 -1023 -1024 -1025 -1026 -1027 -1028 -1029 -1030 -1031
#![allow(non_camel_case_types, non_snake_case)]
+948
#![allow(non_camel_case_types, non_snake_case)]
 
 use crate::advapi::{ffi, iterators::*};
 use crate::co;
@@ -1388,29 +1305,7 @@
 	///     co::RRF::RT_ANY,
 	/// )?;
 	///
-	/// match val {
-	///     w::RegistryValue::Dword(n) => println!("Number u32: {}", n),
-	///     w::RegistryValue::Qword(n) => println!("Number u64: {}", n),
-	///     w::RegistryValue::Sz(s) => println!("String: {}", s),
-	///     w::RegistryValue::ExpandSz(s) => {
-	///         println!("Env string: {}", w::ExpandEnvironmentStrings(&s)?);
-	///     },
-	///     w::RegistryValue::MultiSz(strs) => {
-	///        println!("Multi string:");
-	///        for s in strs.iter() {
-	///            print!("[{}] ", s);
-	///        }
-	///        println!("");
-	///     },
-	///     w::RegistryValue::Binary(bin) => {
-	///         println!("Binary:");
-	///         for b in bin.iter() {
-	///             print!("{:02x} ", b);
-	///         }
-	///         println!("");
-	///     },
-	///     w::RegistryValue::None => println!("No value"),
-	/// }
+	/// println!("{val}");
 	/// # w::SysResult::Ok(())
 	/// ```
 	#[must_use]
@@ -1636,12 +1531,6 @@
 	/// [`RegQueryMultipleValues`](https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regquerymultiplevaluesw)
 	/// function.
 	///
-	/// This method is a multi-value version of
-	/// [`HKEY::RegQueryValueEx`](crate::prelude::advapi_Hkey::RegQueryValueEx).
-	///
-	/// Note that this method validates some race conditions, returning
-	/// [`co::ERROR::TRANSACTION_REQUEST_NOT_VALID`](crate::co::ERROR::TRANSACTION_REQUEST_NOT_VALID).
-	///
 	/// # Examples
 	///
 	/// ```no_run
@@ -1654,29 +1543,7 @@
 	/// )?;
 	///
 	/// for val in hkey.RegQueryMultipleValues(&["DpiScalingVer", "WallPaper"])? {
-	///     match val {
-	///         w::RegistryValue::Dword(n) => println!("Number u32: {}", n),
-	///         w::RegistryValue::Qword(n) => println!("Number u64: {}", n),
-	///         w::RegistryValue::Sz(s) => println!("String: {}", s),
-	///         w::RegistryValue::ExpandSz(s) => {
-	///             println!("Env string: {}", w::ExpandEnvironmentStrings(&s)?);
-	///         },
-	///         w::RegistryValue::MultiSz(strs) => {
-	///            println!("Multi string:");
-	///            for s in strs.iter() {
-	///                print!("[{}] ", s);
-	///            }
-	///            println!("");
-	///         },
-	///         w::RegistryValue::Binary(bin) => {
-	///             println!("Binary:");
-	///             for b in bin.iter() {
-	///                 print!("{:02x} ", b);
-	///             }
-	///             println!("");
-	///         },
-	///         w::RegistryValue::None => println!("No value"),
-	///     }
+	///     println!("{val}");
 	/// }
 	///
 	/// # w::SysResult::Ok(())
@@ -1686,71 +1553,61 @@
 		value_names: &[impl AsRef<str>],
 	) -> SysResult<Vec<RegistryValue>>
 	{
-		let mut valents1 = vec![VALENT::default(); value_names.len()];
+		let mut valents = vec![VALENT::default(); value_names.len()];
 		let value_names_w = value_names.iter()
-			.zip(valents1.iter_mut())
-			.map(|(value_name, valent)| {
-				let value_name_w = WString::from_str(value_name.as_ref());
-				valent.ve_valuename = value_name_w.as_ptr() as _;
-				value_name_w
-			})
+			.map(|value_name| WString::from_str(value_name.as_ref()))
 			.collect::<Vec<_>>();
-		let mut data_len1 = u32::default();
+		valents.iter_mut()
+			.zip(value_names_w.iter())
+			.for_each(|(valent, value_name_w)| valent.ve_valuename = value_name_w.as_ptr() as _);
+		let mut buf = Vec::<u8>::default();
 
-		// Query data types and lenghts.
-		match unsafe {
-			co::ERROR::from_raw(
-				ffi::RegQueryMultipleValuesW(
-					self.ptr(),
-					valents1.as_mut_ptr() as _,
-					value_names.len() as _,
-					std::ptr::null_mut(),
-					&mut data_len1,
-				) as _,
-			 )
-		} {
-			co::ERROR::MORE_DATA => {},
-			err => return Err(err),
-		}
+		loop {
+			let mut data_len = u32::default();
 
-		// Alloc the receiving block.
-		let mut buf: Vec<u8> = vec![0x00; data_len1 as _];
+			match unsafe {
+				co::ERROR::from_raw(
+					ffi::RegQueryMultipleValuesW(
+						self.ptr(),
+						valents.as_mut_ptr() as _,
+						value_names.len() as _,
+						std::ptr::null_mut(),
+						&mut data_len, // first call to retrieve size only
+					) as _,
+				 )
+			} {
+				co::ERROR::MORE_DATA => {},
+				e => return Err(e),
+			}
 
-		let mut valents2 = value_names_w.iter()
-			.map(|value_name_w| {
-				let mut valent = VALENT::default();
-				valent.ve_valuename = value_name_w.as_ptr() as _;
-				valent
-			})
-			.collect::<Vec<_>>();
-		let mut data_len2 = data_len1;
+			buf.resize(data_len as _, 0x00);
 
-		// Retrieve the values content.
-		error_to_sysresult(
-			unsafe {
-				ffi::RegQueryMultipleValuesW(
-					self.ptr(),
-					valents2.as_mut_ptr() as _,
-					value_names.len() as _,
-					buf.as_mut_ptr() as _,
-					&mut data_len2,
+			match unsafe {
+				co::ERROR::from_raw(
+					ffi::RegQueryMultipleValuesW(
+						self.ptr(),
+						valents.as_mut_ptr() as _,
+						value_names.len() as _,
+						buf.as_mut_ptr() as _,
+						&mut data_len,
+					) as _,
 				)
-			},
-		)?;
-
-		if data_len1 != data_len2 {
-			// Race condition: someone modified the data content in between our calls.
-			return Err(co::ERROR::TRANSACTION_REQUEST_NOT_VALID);
+			} {
+				co::ERROR::SUCCESS => {
+					buf.resize(data_len as _, 0x00); // data length may have shrunk
+					return valents.iter()
+						.map(|valent| unsafe {
+							RegistryValue::from_raw(
+								valent.buf_projection(&buf).to_vec(),
+								valent.ve_type,
+							)
+						})
+						.collect::<SysResult<Vec<_>>>()
+				},
+				co::ERROR::MORE_DATA => continue, // value changed in a concurrent operation; retry
+				e => return Err(e),
+			}
 		}
-
-		valents2.iter() // first VALENT array is not filled with len/type values
-			.map(|v2| unsafe {
-				RegistryValue::from_raw(
-					v2.buf_projection(&buf).to_vec(),
-					v2.ve_type,
-				)
-			})
-			.collect::<SysResult<Vec<_>>>()
 	}
 
 	/// [`RegQueryReflectionKey`](https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regqueryreflectionkey)
@@ -1778,30 +1635,7 @@
 	/// )?;
 	///
 	/// let val = hkey.RegQueryValueEx(Some("Beep"))?;
-	///
-	/// match val {
-	///     w::RegistryValue::Dword(n) => println!("Number u32: {}", n),
-	///     w::RegistryValue::Qword(n) => println!("Number u64: {}", n),
-	///     w::RegistryValue::Sz(s) => println!("String: {}", s),
-	///     w::RegistryValue::ExpandSz(s) => {
-	///         println!("Env string: {}", w::ExpandEnvironmentStrings(&s)?);
-	///     },
-	///     w::RegistryValue::MultiSz(strs) => {
-	///        println!("Multi string:");
-	///        for s in strs.iter() {
-	///            print!("[{}] ", s);
-	///        }
-	///        println!("");
-	///     },
-	///     w::RegistryValue::Binary(bin) => {
-	///         println!("Binary:");
-	///         for b in bin.iter() {
-	///             print!("{:02x} ", b);
-	///         }
-	///         println!("");
-	///     },
-	///     w::RegistryValue::None => println!("No value"),
-	/// }
+	/// println!("{val}");
 	/// # w::SysResult::Ok(())
 	/// ```
 	#[must_use]
diff --git a/winsafe/prelude/trait.advapi_Hkey.html b/winsafe/prelude/trait.advapi_Hkey.html
index dd83b6f24c..3652c78c54 100644
--- a/winsafe/prelude/trait.advapi_Hkey.html
+++ b/winsafe/prelude/trait.advapi_Hkey.html
@@ -1,4 +1,4 @@
-advapi_Hkey in winsafe::prelude - Rust

Trait advapi_Hkey

Source
pub trait advapi_Hkey: Handle {
+advapi_Hkey in winsafe::prelude - Rust

Trait advapi_Hkey

Source
pub trait advapi_Hkey: Handle {
     const CLASSES_ROOT: HKEY = _;
     const CURRENT_USER: HKEY = _;
     const LOCAL_MACHINE: HKEY = _;
@@ -257,7 +257,7 @@ 
§Examples
.collect::<w::SysResult<Vec<_>>>()?;
Source

fn RegFlushKey(&self) -> SysResult<()>

RegFlushKey function.

-
Source

fn RegGetValue( +

Source

fn RegGetValue( &self, sub_key: Option<&str>, value_name: Option<&str>, @@ -273,34 +273,12 @@

§Examples
co::RRF::RT_ANY, )?; -match val { - w::RegistryValue::Dword(n) => println!("Number u32: {}", n), - w::RegistryValue::Qword(n) => println!("Number u64: {}", n), - w::RegistryValue::Sz(s) => println!("String: {}", s), - w::RegistryValue::ExpandSz(s) => { - println!("Env string: {}", w::ExpandEnvironmentStrings(&s)?); - }, - w::RegistryValue::MultiSz(strs) => { - println!("Multi string:"); - for s in strs.iter() { - print!("[{}] ", s); - } - println!(""); - }, - w::RegistryValue::Binary(bin) => { - println!("Binary:"); - for b in bin.iter() { - print!("{:02x} ", b); - } - println!(""); - }, - w::RegistryValue::None => println!("No value"), -}
-
Source

fn RegLoadKey(&self, sub_key: Option<&str>, file_path: &str) -> SysResult<()>

RegLoadKey +println!("{val}");

+
Source

fn RegLoadKey(&self, sub_key: Option<&str>, file_path: &str) -> SysResult<()>

RegLoadKey function.

-
Source

fn RegOpenCurrentUser(access_rights: KEY) -> SysResult<RegCloseKeyGuard>

Source

fn RegOpenCurrentUser(access_rights: KEY) -> SysResult<RegCloseKeyGuard>

RegOpenCurrentUser function.

-
Source

fn RegOpenKeyEx( +

Source

fn RegOpenKeyEx( &self, sub_key: Option<&str>, options: REG_OPTION, @@ -315,7 +293,7 @@

§Examples
co::REG_OPTION::default(), co::KEY::READ, )?; -
Source

fn RegOpenKeyTransacted( +

Source

fn RegOpenKeyTransacted( &self, sub_key: &str, options: REG_OPTION, @@ -323,7 +301,7 @@

§Examples
htransaction: &HTRANSACTION, ) -> SysResult<RegCloseKeyGuard>
Source

fn RegQueryInfoKey( +

Source

fn RegQueryInfoKey( &self, class: Option<&mut WString>, num_sub_keys: Option<&mut u32>, @@ -336,15 +314,11 @@

§Examples
last_write_time: Option<&mut FILETIME>, ) -> SysResult<()>

RegQueryInfoKey function.

-
Source

fn RegQueryMultipleValues( +

Source

fn RegQueryMultipleValues( &self, value_names: &[impl AsRef<str>], ) -> SysResult<Vec<RegistryValue>>

RegQueryMultipleValues function.

-

This method is a multi-value version of -HKEY::RegQueryValueEx.

-

Note that this method validates some race conditions, returning -co::ERROR::TRANSACTION_REQUEST_NOT_VALID.

§Examples
use winsafe::{self as w, prelude::*, co};
 
@@ -355,34 +329,12 @@ 
§Examples
)?; for val in hkey.RegQueryMultipleValues(&["DpiScalingVer", "WallPaper"])? { - match val { - w::RegistryValue::Dword(n) => println!("Number u32: {}", n), - w::RegistryValue::Qword(n) => println!("Number u64: {}", n), - w::RegistryValue::Sz(s) => println!("String: {}", s), - w::RegistryValue::ExpandSz(s) => { - println!("Env string: {}", w::ExpandEnvironmentStrings(&s)?); - }, - w::RegistryValue::MultiSz(strs) => { - println!("Multi string:"); - for s in strs.iter() { - print!("[{}] ", s); - } - println!(""); - }, - w::RegistryValue::Binary(bin) => { - println!("Binary:"); - for b in bin.iter() { - print!("{:02x} ", b); - } - println!(""); - }, - w::RegistryValue::None => println!("No value"), - } + println!("{val}"); }
-
Source

fn RegQueryReflectionKey(&self) -> SysResult<bool>

Source

fn RegQueryReflectionKey(&self) -> SysResult<bool>

Source

fn RegQueryValueEx(&self, value_name: Option<&str>) -> SysResult<RegistryValue>

Source

fn RegQueryValueEx(&self, value_name: Option<&str>) -> SysResult<RegistryValue>

RegQueryValueEx function.

§Examples
use winsafe::{self as w, prelude::*, co};
@@ -394,55 +346,32 @@ 
§Examples
)?; let val = hkey.RegQueryValueEx(Some("Beep"))?; - -match val { - w::RegistryValue::Dword(n) => println!("Number u32: {}", n), - w::RegistryValue::Qword(n) => println!("Number u64: {}", n), - w::RegistryValue::Sz(s) => println!("String: {}", s), - w::RegistryValue::ExpandSz(s) => { - println!("Env string: {}", w::ExpandEnvironmentStrings(&s)?); - }, - w::RegistryValue::MultiSz(strs) => { - println!("Multi string:"); - for s in strs.iter() { - print!("[{}] ", s); - } - println!(""); - }, - w::RegistryValue::Binary(bin) => { - println!("Binary:"); - for b in bin.iter() { - print!("{:02x} ", b); - } - println!(""); - }, - w::RegistryValue::None => println!("No value"), -}
-
Source

fn RegRenameKey(&self, sub_key_name: &str, new_key_name: &str) -> SysResult<()>

RegRenameKey +println!("{val}");

+
Source

fn RegRenameKey(&self, sub_key_name: &str, new_key_name: &str) -> SysResult<()>

RegRenameKey function.

-
Source

fn RegReplaceKey( +

Source

fn RegReplaceKey( &self, sub_key: Option<&str>, new_src_file: &str, old_file_backup: &str, ) -> SysResult<()>

RegReplaceKey function.

-
Source

fn RegRestoreKey(&self, file_path: &str, flags: REG_RESTORE) -> SysResult<()>

Source

fn RegRestoreKey(&self, file_path: &str, flags: REG_RESTORE) -> SysResult<()>

RegRestoreKey function.

-
Source

fn RegSaveKey( +

Source

fn RegSaveKey( &self, dest_file_path: &str, security_attributes: Option<&SECURITY_ATTRIBUTES<'_>>, ) -> SysResult<()>

RegSaveKey function.

-
Source

fn RegSaveKeyEx( +

Source

fn RegSaveKeyEx( &self, dest_file_path: &str, security_attributes: Option<&SECURITY_ATTRIBUTES<'_>>, flags: REG_SAVE, ) -> SysResult<()>

RegSaveKeyEx function.

-
Source

fn RegSetKeyValue( +

Source

fn RegSetKeyValue( &self, sub_key: Option<&str>, value_name: Option<&str>, @@ -459,7 +388,7 @@

§Examples
Some("Color"), w::RegistryValue::Sz("blue".to_owned()), )?; -
Source

fn RegSetValueEx( +

Source

fn RegSetValueEx( &self, value_name: Option<&str>, data: RegistryValue, @@ -480,6 +409,6 @@

§Examples
Some("Color"), w::RegistryValue::Sz("blue".to_owned()), )?; -
Source

fn RegUnLoadKey(&self, sub_key: Option<&str>) -> SysResult<()>

Source

fn RegUnLoadKey(&self, sub_key: Option<&str>) -> SysResult<()>

RegUnLoadKey function.

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.

Implementors§

Source§

impl advapi_Hkey for HKEY

\ No newline at end of file diff --git a/winsafe/struct.HKEY.html b/winsafe/struct.HKEY.html index 90f18ba750..8664d4659a 100644 --- a/winsafe/struct.HKEY.html +++ b/winsafe/struct.HKEY.html @@ -53,28 +53,28 @@ ) -> SysResult<impl Iterator<Item = SysResult<(String, REG)>> + '_>
Returns an iterator of the names and types of the values, which calls RegEnumValue repeatedly. Read more
Source§

fn RegFlushKey(&self) -> SysResult<()>

RegFlushKey -function.
Source§

fn RegGetValue( +function.

Source§

fn RegGetValue( &self, sub_key: Option<&str>, value_name: Option<&str>, flags: RRF, ) -> SysResult<RegistryValue>

Source§

fn RegLoadKey(&self, sub_key: Option<&str>, file_path: &str) -> SysResult<()>

RegLoadKey -function.
Source§

fn RegOpenCurrentUser(access_rights: KEY) -> SysResult<RegCloseKeyGuard>

Source§

fn RegOpenKeyEx( +function. Read more

Source§

fn RegLoadKey(&self, sub_key: Option<&str>, file_path: &str) -> SysResult<()>

RegLoadKey +function.
Source§

fn RegOpenCurrentUser(access_rights: KEY) -> SysResult<RegCloseKeyGuard>

Source§

fn RegOpenKeyEx( &self, sub_key: Option<&str>, options: REG_OPTION, access_rights: KEY, ) -> SysResult<RegCloseKeyGuard>

Source§

fn RegOpenKeyTransacted( +function. Read more

Source§

fn RegOpenKeyTransacted( &self, sub_key: &str, options: REG_OPTION, access_rights: KEY, htransaction: &HTRANSACTION, ) -> SysResult<RegCloseKeyGuard>

Source§

fn RegQueryInfoKey( +function.

Source§

fn RegQueryInfoKey( &self, class: Option<&mut WString>, num_sub_keys: Option<&mut u32>, @@ -86,43 +86,43 @@ security_descr_len: Option<&mut u32>, last_write_time: Option<&mut FILETIME>, ) -> SysResult<()>

RegQueryInfoKey -function.
Source§

fn RegQueryMultipleValues( +function.

Source§

fn RegQueryMultipleValues( &self, value_names: &[impl AsRef<str>], ) -> SysResult<Vec<RegistryValue>>

Source§

fn RegQueryReflectionKey(&self) -> SysResult<bool>

Source§

fn RegQueryValueEx(&self, value_name: Option<&str>) -> SysResult<RegistryValue>

Source§

fn RegRenameKey(&self, sub_key_name: &str, new_key_name: &str) -> SysResult<()>

RegRenameKey -function.
Source§

fn RegReplaceKey( +function. Read more

Source§

fn RegQueryReflectionKey(&self) -> SysResult<bool>

Source§

fn RegQueryValueEx(&self, value_name: Option<&str>) -> SysResult<RegistryValue>

Source§

fn RegRenameKey(&self, sub_key_name: &str, new_key_name: &str) -> SysResult<()>

RegRenameKey +function.
Source§

fn RegReplaceKey( &self, sub_key: Option<&str>, new_src_file: &str, old_file_backup: &str, ) -> SysResult<()>

RegReplaceKey -function.
Source§

fn RegRestoreKey(&self, file_path: &str, flags: REG_RESTORE) -> SysResult<()>

RegRestoreKey -function.
Source§

fn RegSaveKey( +function.

Source§

fn RegRestoreKey(&self, file_path: &str, flags: REG_RESTORE) -> SysResult<()>

RegRestoreKey +function.
Source§

fn RegSaveKey( &self, dest_file_path: &str, security_attributes: Option<&SECURITY_ATTRIBUTES<'_>>, ) -> SysResult<()>

RegSaveKey -function.
Source§

fn RegSaveKeyEx( +function.

Source§

fn RegSaveKeyEx( &self, dest_file_path: &str, security_attributes: Option<&SECURITY_ATTRIBUTES<'_>>, flags: REG_SAVE, ) -> SysResult<()>

RegSaveKeyEx -function.
Source§

fn RegSetKeyValue( +function.

Source§

fn RegSetKeyValue( &self, sub_key: Option<&str>, value_name: Option<&str>, data: RegistryValue, ) -> SysResult<()>

Source§

fn RegSetValueEx( +function. Read more

Source§

fn RegSetValueEx( &self, value_name: Option<&str>, data: RegistryValue, ) -> SysResult<()>

Source§

fn RegUnLoadKey(&self, sub_key: Option<&str>) -> SysResult<()>

Source§

fn RegUnLoadKey(&self, sub_key: Option<&str>) -> SysResult<()>

RegUnLoadKey function.
Source§

impl Eq for HKEY

Source§

impl Send for HKEY

Source§

impl StructuralPartialEq for HKEY

Auto Trait Implementations§

§

impl Freeze for HKEY

§

impl RefUnwindSafe for HKEY

§

impl !Sync for HKEY

§

impl Unpin for HKEY

§

impl UnwindSafe for HKEY

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