@@ -17,9 +17,9 @@ pub struct Meta {
1717 pub kind : Kind ,
1818}
1919
20- #[ repr( u8 ) ]
2120#[ derive( Debug , Clone , Copy , PartialEq , Eq , strum:: Display ) ]
2221#[ strum( serialize_all = "lowercase" ) ]
22+ #[ repr( u8 ) ]
2323pub enum Dependency {
2424 /// Just the plain name of a package
2525 #[ strum( serialize = "name" ) ]
@@ -50,9 +50,10 @@ pub enum Dependency {
5050
5151 /// An emul32-compatible pkgconfig .pc dependency (lib32/*.pc)
5252 PkgConfig32 ,
53+
54+ Unknown = 255 ,
5355}
5456
55- #[ repr( u8 ) ]
5657#[ derive( Debug , Clone , PartialEq , Eq ) ]
5758pub enum Kind {
5859 Int8 ( i8 ) ,
@@ -66,6 +67,7 @@ pub enum Kind {
6667 String ( String ) ,
6768 Dependency ( Dependency , String ) ,
6869 Provider ( Dependency , String ) ,
70+ Unknown ( Vec < u8 > ) ,
6971}
7072
7173impl Kind {
@@ -85,58 +87,61 @@ impl Kind {
8587 Kind :: Dependency ( _, s) => s. len ( ) + 2 ,
8688 // Plus dep size & nul terminator
8789 Kind :: Provider ( _, s) => s. len ( ) + 2 ,
90+ Kind :: Unknown ( data) => data. len ( ) ,
8891 }
8992 }
9093}
9194
92- #[ repr( u16 ) ]
9395#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
96+ #[ repr( u16 ) ]
9497pub enum Tag {
9598 // Name of the package
9699 Name = 1 ,
97100 // Architecture of the package
98- Architecture = 2 ,
101+ Architecture ,
99102 // Version of the package
100- Version = 3 ,
103+ Version ,
101104 // Summary of the package
102- Summary = 4 ,
105+ Summary ,
103106 // Description of the package
104- Description = 5 ,
107+ Description ,
105108 // Homepage for the package
106- Homepage = 6 ,
109+ Homepage ,
107110 // ID for the source package, used for grouping
108- SourceID = 7 ,
111+ SourceID ,
109112 // Runtime dependencies
110- Depends = 8 ,
113+ Depends ,
111114 // Provides some capability or name
112- Provides = 9 ,
115+ Provides ,
113116 // Conflicts with some capability or name
114- Conflicts = 10 ,
117+ Conflicts ,
115118 // Release number for the package
116- Release = 11 ,
119+ Release ,
117120 // SPDX license identifier
118- License = 12 ,
121+ License ,
119122 // Currently recorded build number
120- BuildRelease = 13 ,
123+ BuildRelease ,
121124 // Repository index specific (relative URI)
122- PackageURI = 14 ,
125+ PackageURI ,
123126 // Repository index specific (Package hash)
124- PackageHash = 15 ,
127+ PackageHash ,
125128 // Repository index specific (size on disk)
126- PackageSize = 16 ,
129+ PackageSize ,
127130 // A Build Dependency
128- BuildDepends = 17 ,
131+ BuildDepends ,
129132 // Upstream URI for the source
130- SourceURI = 18 ,
133+ SourceURI ,
131134 // Relative path for the source within the upstream URI
132- SourcePath = 19 ,
135+ SourcePath ,
133136 // Ref/commit of the upstream source
134- SourceRef = 20 ,
137+ SourceRef ,
138+
139+ Unknown = u16:: MAX ,
135140}
136141
137142/// Helper to decode a dependency's encoded kind
138- fn decode_dependency ( i : u8 ) -> Result < Dependency , DecodeError > {
139- let result = match i {
143+ fn decode_dependency ( i : u8 ) -> Dependency {
144+ match i {
140145 0 => Dependency :: PackageName ,
141146 1 => Dependency :: SharedLibrary ,
142147 2 => Dependency :: PkgConfig ,
@@ -146,9 +151,8 @@ fn decode_dependency(i: u8) -> Result<Dependency, DecodeError> {
146151 6 => Dependency :: Binary ,
147152 7 => Dependency :: SystemBinary ,
148153 8 => Dependency :: PkgConfig32 ,
149- _ => return Err ( DecodeError :: UnknownDependency ( i) ) ,
150- } ;
151- Ok ( result)
154+ _ => Dependency :: Unknown ,
155+ }
152156}
153157
154158impl Record for Meta {
@@ -176,7 +180,7 @@ impl Record for Meta {
176180 18 => Tag :: SourceURI ,
177181 19 => Tag :: SourcePath ,
178182 20 => Tag :: SourceRef ,
179- t => return Err ( DecodeError :: UnknownMetaTag ( t ) ) ,
183+ _ => Tag :: Unknown ,
180184 } ;
181185
182186 let kind = reader. read_u8 ( ) ?;
@@ -197,15 +201,15 @@ impl Record for Meta {
197201 9 => Kind :: String ( sanitize ( reader. read_string ( length as u64 ) ?) ) ,
198202 10 => Kind :: Dependency (
199203 // DependencyKind u8 subtracted from length
200- decode_dependency ( reader. read_u8 ( ) ?) ? ,
204+ decode_dependency ( reader. read_u8 ( ) ?) ,
201205 sanitize ( reader. read_string ( length as u64 - 1 ) ?) ,
202206 ) ,
203207 11 => Kind :: Provider (
204208 // DependencyKind u8 subtracted from length
205- decode_dependency ( reader. read_u8 ( ) ?) ? ,
209+ decode_dependency ( reader. read_u8 ( ) ?) ,
206210 sanitize ( reader. read_string ( length as u64 - 1 ) ?) ,
207211 ) ,
208- k => return Err ( DecodeError :: UnknownMetaKind ( k ) ) ,
212+ _ => Kind :: Unknown ( reader . read_vec ( length as usize ) ? ) ,
209213 } ;
210214
211215 Ok ( Self { tag, kind } )
@@ -224,6 +228,7 @@ impl Record for Meta {
224228 Kind :: String ( _) => 9 ,
225229 Kind :: Dependency ( _, _) => 10 ,
226230 Kind :: Provider ( _, _) => 11 ,
231+ Kind :: Unknown ( _) => 255 ,
227232 } ;
228233
229234 writer. write_u32 ( self . kind . size ( ) as u32 ) ?;
@@ -250,6 +255,9 @@ impl Record for Meta {
250255 writer. write_all ( s. as_bytes ( ) ) ?;
251256 writer. write_u8 ( b'\0' ) ?;
252257 }
258+ Kind :: Unknown ( data) => {
259+ writer. write_all ( data) ?;
260+ }
253261 }
254262
255263 Ok ( ( ) )
0 commit comments