From edb9d0a14dbb2c7942f7e2f5b13d5fde04cec97c Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Wed, 6 May 2026 21:39:13 +0800 Subject: [PATCH] feat: add some lowlevel functions --- wfassoc/src/lowlevel.rs | 128 ++++++++++++++++++++++++++++++++++------ 1 file changed, 110 insertions(+), 18 deletions(-) diff --git a/wfassoc/src/lowlevel.rs b/wfassoc/src/lowlevel.rs index 1437ffb..ca917c0 100644 --- a/wfassoc/src/lowlevel.rs +++ b/wfassoc/src/lowlevel.rs @@ -454,43 +454,43 @@ impl AppPathsKey { .ok_or(Error::InexistantKey) } - const NAMEOF_PATH_TO_APPLICATION: &str = ""; + const NAMEOF_DEFAULT: &str = ""; - /// - /// + /// + /// /// This field point to the fully qualified path to the application. pub fn get_default(&self, scope: Scope) -> Result { let key = self.open_scope_for_getter(scope)?; - Ok(key.get_value(Self::NAMEOF_PATH_TO_APPLICATION)?) + Ok(key.get_value(Self::NAMEOF_DEFAULT)?) } - /// - /// + /// + /// /// This field should be filled with fully qualified path to the application. pub fn set_default(&mut self, scope: Scope, value: &str) -> Result<(), Error> { let key = self.open_scope_for_setter(scope)?; - key.set_value(Self::NAMEOF_PATH_TO_APPLICATION, &value)?; + key.set_value(Self::NAMEOF_DEFAULT, &value)?; Ok(()) } - const NAMEOF_APPLICATION_DIRECTORY: &str = "Path"; + const NAMEOF_PATH: &str = "Path"; - /// - /// + /// + /// /// This field point to the added path for PATH environment variable. /// Usually it is the path to application directory. pub fn get_path(&self, scope: Scope) -> Result { let key = self.open_scope_for_getter(scope)?; - Ok(key.get_value(Self::NAMEOF_APPLICATION_DIRECTORY)?) + Ok(key.get_value(Self::NAMEOF_PATH)?) } - /// - /// + /// + /// /// This field should be the added path for PATH environment variable. /// Usually it is the path to application directory. pub fn set_path(&mut self, scope: Scope, value: &str) -> Result<(), Error> { let key = self.open_scope_for_setter(scope)?; - key.set_value(Self::NAMEOF_APPLICATION_DIRECTORY, &value)?; + key.set_value(Self::NAMEOF_PATH, &value)?; Ok(()) } } @@ -603,10 +603,6 @@ impl ApplicationsKey { const NAMEOF_SHELL_VERB_PART1: &str = "shell"; const NAMEOF_SHELL_VERB_PART3: &str = "command"; - // TODO: - // We temporarily use String and &str as the command line argument parameter. - // We may introduce a new complete Rust struct for replacing this arbitrary string. - pub fn get_shell_verb(&self, view: View) -> Result { todo!() } @@ -725,6 +721,47 @@ impl ExtKey { // okey Ok(OpenedKey::new(classes, this_ext)) } + + // YYC MARK: + // We do not support "Content Type" and "PerceivedType" + // because current interface are enough to use, + // and these types has not been made as concept struct in Rust. + + const NAMEOF_DEFAULT: &str = ""; + + pub fn get_default(&self, view: View) -> Result, Error> { + todo!() + } + + pub fn set_default(&mut self, scope: Scope, pid: Option<&LosseProgId>) -> Result<(), Error> { + todo!() + } + + const NAMEOF_OPEN_WITH_PROGIDS: &str = "OpenWithProgIds"; + + pub fn get_open_with_progids(&self, view: View) -> Result, Error> { + todo!() + } + + pub fn is_in_open_with_progids(&self, view: View, pid: &LosseProgId) -> Result { + todo!() + } + + pub fn add_into_open_with_progids( + &mut self, + scope: Scope, + pid: &LosseProgId, + ) -> Result<(), Error> { + todo!() + } + + pub fn remove_from_open_with_progids( + &mut self, + scope: Scope, + pid: &LosseProgId, + ) -> Result<(), Error> { + todo!() + } } // endregion @@ -746,4 +783,59 @@ impl ProgIdKey { } } +impl ProgIdKey { + const FULL_CLASSES: &str = "Software\\Classes"; + const PARTIAL_CLASSES: &str = ""; + + fn open_key( + &self, + territory: OpenKeyTerritory, + purpose: OpenKeyPurpose, + ) -> Result { + todo!() + } + + // YYC MARK: + // Currently we only support (Default), FriendlyTypeName and DefaultIcon + // to just cover the basic usage. + + const NAMEOF_DEFAULT: &str = ""; + + pub fn get_default(&self, view: View) -> Result, Error> { + todo!() + } + + pub fn set_default(&mut self, scope: Scope, name: Option<&StrResVariant>) -> Result<(), Error> { + todo!() + } + + const NAMEOF_FRIENDLY_TYPE_NAME: &str = "FriendlyTypeName"; + + pub fn get_friendly_type_name(&self, view: View) -> Result, Error> { + todo!() + } + + pub fn set_friendly_type_name( + &self, + scope: Scope, + name: Option<&StrResVariant>, + ) -> Result<(), Error> { + todo!() + } + + const NAMEOF_DEFAULT_ICON: &str = "DefaultIcon"; + + pub fn get_default_icon(&self, view: View) -> Result, Error> { + todo!() + } + + pub fn set_default_icon( + &self, + scope: Scope, + icon: Option<&IconResVariant>, + ) -> Result<(), Error> { + todo!() + } +} + // endregion