@@ -45,6 +45,24 @@ use std::{
4545} ;
4646use thiserror:: Error ;
4747
48+ /// Dotted-quad version for SDK folder parsing (e.g., "10.0.19041.0").
49+ #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Debug ) ]
50+ struct Version4 ( u32 , u32 , u32 , u32 ) ;
51+
52+ impl Version4 {
53+ fn parse ( s : & str ) -> Result < Self , ( ) > {
54+ let mut it = s. split ( '.' ) ;
55+ let a = it. next ( ) . ok_or ( ( ) ) ?. parse ( ) . map_err ( |_| ( ) ) ?;
56+ let b = it. next ( ) . ok_or ( ( ) ) ?. parse ( ) . map_err ( |_| ( ) ) ?;
57+ let c = it. next ( ) . ok_or ( ( ) ) ?. parse ( ) . map_err ( |_| ( ) ) ?;
58+ let d = it. next ( ) . ok_or ( ( ) ) ?. parse ( ) . map_err ( |_| ( ) ) ?;
59+ if it. next ( ) . is_some ( ) {
60+ return Err ( ( ) ) ;
61+ }
62+ Ok ( Self ( a, b, c, d) )
63+ }
64+ }
65+
4866/// Errors that can occur during MSIX packaging operations.
4967#[ derive( Debug , Error ) ]
5068pub enum MsixError {
@@ -740,23 +758,6 @@ pub fn validate_package(tools: &SdkTools, msix_or_bundle: &Path) -> Result<()> {
740758mod tests {
741759 use super :: * ;
742760
743- // dotted-quad version for SDK folders
744- #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Debug ) ]
745- struct Version4 ( u32 , u32 , u32 , u32 ) ;
746- impl Version4 {
747- fn parse ( s : & str ) -> Result < Self , ( ) > {
748- let mut it = s. split ( '.' ) ;
749- let a = it. next ( ) . ok_or ( ( ) ) ?. parse ( ) . map_err ( |_| ( ) ) ?;
750- let b = it. next ( ) . ok_or ( ( ) ) ?. parse ( ) . map_err ( |_| ( ) ) ?;
751- let c = it. next ( ) . ok_or ( ( ) ) ?. parse ( ) . map_err ( |_| ( ) ) ?;
752- let d = it. next ( ) . ok_or ( ( ) ) ?. parse ( ) . map_err ( |_| ( ) ) ?;
753- if it. next ( ) . is_some ( ) {
754- return Err ( ( ) ) ;
755- }
756- Ok ( Self ( a, b, c, d) )
757- }
758- }
759-
760761 #[ test]
761762 fn sanitize_removes_invalid_chars ( ) {
762763 assert_eq ! ( sanitize( "My:App" ) , "MyApp" ) ;
0 commit comments