@@ -33,18 +33,29 @@ pub fn families() -> io::Result<impl Iterator<Item = PackageFamilyName>> { imp::
33
33
/// ```
34
34
pub fn packages ( ) -> io:: Result < impl Iterator < Item = PackageFullName > > { imp:: packages ( ) }
35
35
36
+ /// Get the [PackageFullName]s installed on this computer for a given [PackageFamilyName]
37
+ ///
38
+ /// ### Examples
39
+ ///
40
+ /// ```rust
41
+ /// let fam = appx::PackageFamilyName::new("NcsiUwpApp_8wekyb3d8bbwe");
42
+ /// for pkg in appx::repository::packages_for_family(&fam).unwrap() {
43
+ /// println!("{}", pkg);
44
+ /// }
45
+ /// ```
46
+ pub fn packages_for_family ( family : & PackageFamilyName ) -> io:: Result < impl Iterator < Item = PackageFullName > > { imp:: packages_for_family ( family) }
47
+
48
+
36
49
/// Check if the [PackageFamilyName] appears on this computer
37
- pub fn has_family ( fam : impl Into < PackageFamilyName > ) -> bool {
50
+ pub fn has_family ( fam : & PackageFamilyName ) -> bool {
38
51
if !cfg ! ( windows) { return false ; }
39
- let fam = fam. into ( ) ;
40
52
let key = reg:: Key :: hkcr ( winstr0 ! ( r"Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Families" ) , reg:: Options :: NONE , reg:: SAM :: READ_ONLY ) ;
41
53
key. ok ( ) . and_then ( |key| key. subkey ( fam. units0 ( ) , reg:: Options :: NONE , reg:: SAM :: READ_ONLY ) . ok ( ) ) . is_some ( )
42
54
}
43
55
44
56
/// Check if the [PackageFullName] appears on this computer
45
- pub fn has_package ( pfn : impl Into < PackageFullName > ) -> bool {
57
+ pub fn has_package ( pfn : & PackageFullName ) -> bool {
46
58
if !cfg ! ( windows) { return false ; }
47
- let pfn = pfn. into ( ) ;
48
59
let key = reg:: Key :: hkcr ( winstr0 ! ( r"Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages" ) , reg:: Options :: NONE , reg:: SAM :: READ_ONLY ) ;
49
60
key. ok ( ) . and_then ( |key| key. subkey ( pfn. units0 ( ) , reg:: Options :: NONE , reg:: SAM :: READ_ONLY ) . ok ( ) ) . is_some ( )
50
61
}
@@ -74,6 +85,7 @@ pub fn add_appx_package(path: impl AsRef<Path>) -> io::Result<()> {
74
85
use super :: * ;
75
86
pub ( super ) fn families ( ) -> io:: Result < impl Iterator < Item = PackageFamilyName > > { Ok ( None . into_iter ( ) ) }
76
87
pub ( super ) fn packages ( ) -> io:: Result < impl Iterator < Item = PackageFullName > > { Ok ( None . into_iter ( ) ) }
88
+ pub ( super ) fn packages_for_family ( _family : & PackageFamilyName ) -> io:: Result < impl Iterator < Item = PackageFullName > > { Ok ( None . into_iter ( ) ) }
77
89
}
78
90
79
91
@@ -110,6 +122,14 @@ pub fn add_appx_package(path: impl AsRef<Path>) -> io::Result<()> {
110
122
} )
111
123
}
112
124
125
+ pub ( super ) fn packages_for_family ( family : & PackageFamilyName ) -> io:: Result < impl Iterator < Item = PackageFullName > > {
126
+ Ok ( PackagesIter {
127
+ key : reg:: Key :: hkcr ( winstr0 ! ( r"Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Families" ) , reg:: Options :: NONE , reg:: SAM :: READ_ONLY ) ?
128
+ . subkey ( family. units0 ( ) , reg:: Options :: NONE , reg:: SAM :: READ_ONLY ) ?,
129
+ index : 0 ,
130
+ } )
131
+ }
132
+
113
133
struct PackagesIter {
114
134
key : reg:: Key ,
115
135
index : u32 ,
0 commit comments