1
- use crate :: {
2
- rewrite_wasm, Authors , Description , Homepage , Licenses , Producers , Revision , Source , Version ,
3
- } ;
4
-
1
+ use crate :: { rewrite_wasm, Producers } ;
5
2
use anyhow:: Result ;
6
3
7
4
/// Add metadata (module name, producers) to a WebAssembly file.
@@ -10,6 +7,7 @@ use anyhow::Result;
10
7
/// metadata will be added to the outermost component.
11
8
#[ cfg_attr( feature = "clap" , derive( clap:: Parser ) ) ]
12
9
#[ derive( Debug , Clone , Default ) ]
10
+ #[ non_exhaustive]
13
11
pub struct AddMetadata {
14
12
/// Add a module or component name to the names section
15
13
#[ cfg_attr( feature = "clap" , clap( long, value_name = "NAME" ) ) ]
@@ -30,31 +28,38 @@ pub struct AddMetadata {
30
28
/// Contact details of the people or organization responsible,
31
29
/// encoded as a freeform string.
32
30
#[ cfg_attr( feature = "clap" , clap( long, value_name = "NAME" ) ) ]
33
- pub authors : Option < Authors > ,
31
+ #[ cfg( feature = "oci" ) ]
32
+ pub authors : Option < crate :: Authors > ,
34
33
35
34
/// A human-readable description of the binary
36
35
#[ cfg_attr( feature = "clap" , clap( long, value_name = "NAME" ) ) ]
37
- pub description : Option < Description > ,
36
+ #[ cfg( feature = "oci" ) ]
37
+ pub description : Option < crate :: Description > ,
38
38
39
39
/// License(s) under which contained software is distributed as an SPDX License Expression.
40
40
#[ cfg_attr( feature = "clap" , clap( long, value_name = "NAME" ) ) ]
41
- pub licenses : Option < Licenses > ,
41
+ #[ cfg( feature = "oci" ) ]
42
+ pub licenses : Option < crate :: Licenses > ,
42
43
43
44
/// URL to get source code for building the image
44
45
#[ cfg_attr( feature = "clap" , clap( long, value_name = "NAME" ) ) ]
45
- pub source : Option < Source > ,
46
+ #[ cfg( feature = "oci" ) ]
47
+ pub source : Option < crate :: Source > ,
46
48
47
49
/// URL to find more information on the binary
48
50
#[ cfg_attr( feature = "clap" , clap( long, value_name = "NAME" ) ) ]
49
- pub homepage : Option < Homepage > ,
51
+ #[ cfg( feature = "oci" ) ]
52
+ pub homepage : Option < crate :: Homepage > ,
50
53
51
54
/// Source control revision identifier for the packaged software.
52
55
#[ cfg_attr( feature = "clap" , clap( long, value_name = "NAME" ) ) ]
53
- pub revision : Option < Revision > ,
56
+ #[ cfg( feature = "oci" ) ]
57
+ pub revision : Option < crate :: Revision > ,
54
58
55
59
/// Version of the packaged software
56
60
#[ cfg_attr( feature = "clap" , clap( long, value_name = "NAME" ) ) ]
57
- pub version : Option < Version > ,
61
+ #[ cfg( feature = "oci" ) ]
62
+ pub version : Option < crate :: Version > ,
58
63
}
59
64
60
65
#[ cfg( feature = "clap" ) ]
@@ -69,17 +74,7 @@ impl AddMetadata {
69
74
/// components. The module and component will have, at very least, an empty name and producers
70
75
/// section created.
71
76
pub fn to_wasm ( & self , input : & [ u8 ] ) -> Result < Vec < u8 > > {
72
- rewrite_wasm (
73
- & self . name ,
74
- & Producers :: from_meta ( self ) ,
75
- & self . authors ,
76
- & self . description ,
77
- & self . licenses ,
78
- & self . source ,
79
- & self . homepage ,
80
- & self . revision ,
81
- & self . version ,
82
- input,
83
- )
77
+ let add_producers = Producers :: from_meta ( self ) ;
78
+ rewrite_wasm ( self , & add_producers, input)
84
79
}
85
80
}
0 commit comments