@@ -7,8 +7,8 @@ use serde::Deserialize;
77use strum:: { EnumDiscriminants , EnumTryAs , IntoDiscriminant as _} ;
88
99use crate :: {
10- metadata:: collaborators:: Collaborators , ContentEncoding , ContentType , DocType , DocumentRefs ,
11- Section ,
10+ metadata:: collaborators:: Collaborators , Chain , ContentEncoding , ContentType , DocType ,
11+ DocumentRefs , Section ,
1212} ;
1313
1414/// COSE label. May be either a signed integer or a string.
@@ -100,18 +100,20 @@ pub(crate) enum SupportedField {
100100 Ver ( UuidV7 ) = 3 ,
101101 /// `type` field.
102102 Type ( DocType ) = 4 ,
103+ /// `chain` field.
104+ Chain ( Chain ) = 5 ,
103105 /// `reply` field.
104- Reply ( DocumentRefs ) = 5 ,
106+ Reply ( DocumentRefs ) = 6 ,
105107 /// `section` field.
106- Section ( Section ) = 6 ,
108+ Section ( Section ) = 7 ,
107109 /// `template` field.
108- Template ( DocumentRefs ) = 7 ,
110+ Template ( DocumentRefs ) = 8 ,
109111 /// `parameters` field.
110- Parameters ( DocumentRefs ) = 8 ,
112+ Parameters ( DocumentRefs ) = 9 ,
111113 /// `collaborators` field.
112- Collaborators ( Collaborators ) = 9 ,
114+ Collaborators ( Collaborators ) = 10 ,
113115 /// `Content-Encoding` field.
114- ContentEncoding ( ContentEncoding ) = 10 ,
116+ ContentEncoding ( ContentEncoding ) = 11 ,
115117}
116118
117119impl SupportedLabel {
@@ -124,6 +126,7 @@ impl SupportedLabel {
124126 Label :: Str ( "ref" ) => Some ( Self :: Ref ) ,
125127 Label :: Str ( "ver" ) => Some ( Self :: Ver ) ,
126128 Label :: Str ( "type" ) => Some ( Self :: Type ) ,
129+ Label :: Str ( "chain" ) => Some ( Self :: Chain ) ,
127130 Label :: Str ( "reply" ) => Some ( Self :: Reply ) ,
128131 Label :: Str ( "collaborators" ) => Some ( Self :: Collaborators ) ,
129132 Label :: Str ( "section" ) => Some ( Self :: Section ) ,
@@ -146,6 +149,7 @@ impl SupportedLabel {
146149 Self :: Ref => Label :: Str ( "ref" ) ,
147150 Self :: Ver => Label :: Str ( "ver" ) ,
148151 Self :: Type => Label :: Str ( "type" ) ,
152+ Self :: Chain => Label :: Str ( "chain" ) ,
149153 Self :: Reply => Label :: Str ( "reply" ) ,
150154 Self :: Collaborators => Label :: Str ( "collaborators" ) ,
151155 Self :: Section => Label :: Str ( "section" ) ,
@@ -179,6 +183,7 @@ impl serde::ser::Serialize for SupportedField {
179183 match self {
180184 Self :: Id ( v) | Self :: Ver ( v) => v. serialize ( serializer) ,
181185 Self :: Type ( v) => v. serialize ( serializer) ,
186+ Self :: Chain ( v) => v. serialize ( serializer) ,
182187 Self :: ContentType ( v) => v. serialize ( serializer) ,
183188 Self :: ContentEncoding ( v) => v. serialize ( serializer) ,
184189 Self :: Ref ( v) | Self :: Reply ( v) | Self :: Template ( v) | Self :: Parameters ( v) => {
@@ -205,6 +210,7 @@ impl<'de> serde::de::DeserializeSeed<'de> for SupportedLabel {
205210 SupportedLabel :: Ref => Deserialize :: deserialize ( d) . map ( SupportedField :: Ref ) ,
206211 SupportedLabel :: Ver => Deserialize :: deserialize ( d) . map ( SupportedField :: Ver ) ,
207212 SupportedLabel :: Type => Deserialize :: deserialize ( d) . map ( SupportedField :: Type ) ,
213+ SupportedLabel :: Chain => Deserialize :: deserialize ( d) . map ( SupportedField :: Chain ) ,
208214 SupportedLabel :: Reply => Deserialize :: deserialize ( d) . map ( SupportedField :: Reply ) ,
209215 SupportedLabel :: Collaborators => {
210216 Deserialize :: deserialize ( d) . map ( SupportedField :: Collaborators )
@@ -253,6 +259,7 @@ impl minicbor::Decode<'_, crate::decode_context::DecodeContext> for Option<Suppo
253259 . map ( SupportedField :: Ver )
254260 } ,
255261 SupportedLabel :: Type => d. decode ( ) . map ( SupportedField :: Type ) ,
262+ SupportedLabel :: Chain => d. decode ( ) . map ( SupportedField :: Chain ) ,
256263 SupportedLabel :: Reply => {
257264 d. decode_with ( & mut ctx. policy ( ) . clone ( ) )
258265 . map ( SupportedField :: Reply )
@@ -314,6 +321,7 @@ impl minicbor::Encode<()> for SupportedField {
314321 | SupportedField :: Template ( document_ref)
315322 | SupportedField :: Parameters ( document_ref) => document_ref. encode ( e, ctx) ,
316323 SupportedField :: Type ( doc_type) => doc_type. encode ( e, ctx) ,
324+ SupportedField :: Chain ( chain) => chain. encode ( e, ctx) ,
317325 SupportedField :: Collaborators ( collaborators) => collaborators. encode ( e, ctx) ,
318326 SupportedField :: Section ( section) => section. encode ( e, ctx) ,
319327 SupportedField :: ContentEncoding ( content_encoding) => content_encoding. encode ( e, ctx) ,
0 commit comments