@@ -11,13 +11,14 @@ use url::Url;
11
11
/// This represents the types defined in the [CloudEvent spec type system](https://github.com/cloudevents/spec/blob/v1.0/spec.md#type-system)
12
12
#[ derive( Debug , PartialEq , Eq ) ]
13
13
pub enum AttributeValue < ' a > {
14
- SpecVersion ( SpecVersion ) ,
14
+ Boolean ( & ' a bool ) ,
15
+ Integer ( & ' a i64 ) ,
15
16
String ( & ' a str ) ,
17
+ Binary ( & ' a [ u8 ] ) ,
16
18
URI ( & ' a Url ) ,
17
19
URIRef ( & ' a UriReference ) ,
18
- Boolean ( & ' a bool ) ,
19
- Integer ( & ' a i64 ) ,
20
20
Time ( & ' a DateTime < Utc > ) ,
21
+ SpecVersion ( SpecVersion ) ,
21
22
}
22
23
23
24
impl < ' a > From < & ' a ExtensionValue > for AttributeValue < ' a > {
@@ -33,13 +34,14 @@ impl<'a> From<&'a ExtensionValue> for AttributeValue<'a> {
33
34
impl fmt:: Display for AttributeValue < ' _ > {
34
35
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
35
36
match self {
36
- AttributeValue :: SpecVersion ( s) => s. fmt ( f) ,
37
+ AttributeValue :: Boolean ( b) => f. serialize_bool ( * * b) ,
38
+ AttributeValue :: Integer ( i) => f. serialize_i64 ( * * i) ,
37
39
AttributeValue :: String ( s) => f. write_str ( s) ,
40
+ AttributeValue :: Binary ( b) => f. write_str ( & base64:: encode ( b) ) ,
38
41
AttributeValue :: URI ( s) => f. write_str ( s. as_str ( ) ) ,
39
42
AttributeValue :: URIRef ( s) => f. write_str ( s. as_str ( ) ) ,
40
43
AttributeValue :: Time ( s) => f. write_str ( & s. to_rfc3339 ( ) ) ,
41
- AttributeValue :: Boolean ( b) => f. serialize_bool ( * * b) ,
42
- AttributeValue :: Integer ( i) => f. serialize_i64 ( * * i) ,
44
+ AttributeValue :: SpecVersion ( s) => s. fmt ( f) ,
43
45
}
44
46
}
45
47
}
0 commit comments