@@ -32,6 +32,12 @@ pub struct Metadata {
3232 id : DocumentId ,
3333 /// Document Version `UUIDv7`.
3434 ver : DocumentVersion ,
35+ /// Document Payload Content Type.
36+ #[ serde( default , rename = "content-type" ) ]
37+ content_type : ContentType ,
38+ /// Document Payload Content Encoding.
39+ #[ serde( default , rename = "content-encoding" ) ]
40+ content_encoding : Option < ContentEncoding > ,
3541 /// Reference to the latest document.
3642 #[ serde( rename = "ref" ) ]
3743 doc_ref : Option < DocumentRef > ,
@@ -41,12 +47,6 @@ pub struct Metadata {
4147 reply : Option < DocumentRef > ,
4248 /// Reference to the document section.
4349 section : Option < String > ,
44- /// Document Payload Content Type.
45- #[ serde( default , rename = "content-type" ) ]
46- content_type : Option < ContentType > ,
47- /// Document Payload Content Encoding.
48- #[ serde( default , rename = "content-encoding" ) ]
49- content_encoding : Option < ContentEncoding > ,
5050 /// Metadata Content Errors
5151 #[ serde( skip) ]
5252 content_errors : Vec < String > ,
@@ -109,7 +109,7 @@ impl Metadata {
109109
110110 /// Returns the Document Content Type, if any.
111111 #[ must_use]
112- pub fn content_type ( & self ) -> Option < ContentType > {
112+ pub fn content_type ( & self ) -> ContentType {
113113 self . content_type
114114 }
115115
@@ -130,7 +130,7 @@ impl Display for Metadata {
130130 writeln ! ( f, " template: {:?}," , self . template) ?;
131131 writeln ! ( f, " reply: {:?}," , self . reply) ?;
132132 writeln ! ( f, " section: {:?}" , self . section) ?;
133- writeln ! ( f, " content_type: {:? }" , self . content_type) ?;
133+ writeln ! ( f, " content_type: {}" , self . content_type) ?;
134134 writeln ! ( f, " content_encoding: {:?}" , self . content_encoding) ?;
135135 writeln ! ( f, "}}" )
136136 }
@@ -146,7 +146,7 @@ impl Default for Metadata {
146146 template : None ,
147147 reply : None ,
148148 section : None ,
149- content_type : None ,
149+ content_type : ContentType :: default ( ) ,
150150 content_encoding : None ,
151151 content_errors : Vec :: new ( ) ,
152152 }
@@ -173,7 +173,7 @@ impl From<&coset::ProtectedHeader> for Metadata {
173173 match protected. header . content_type . as_ref ( ) {
174174 Some ( iana_content_type) => {
175175 match ContentType :: try_from ( iana_content_type) {
176- Ok ( content_type) => metadata. content_type = Some ( content_type) ,
176+ Ok ( content_type) => metadata. content_type = content_type,
177177 Err ( e) => {
178178 errors. push ( format ! ( "Invalid Document Content-Type: {e}" ) ) ;
179179 } ,
0 commit comments