@@ -8,7 +8,7 @@ use fe2o3_amqp_lib::types::messaging::{ApplicationProperties, Body, Message, Pro
8
8
use fe2o3_amqp_lib:: types:: primitives:: { Binary , SimpleValue , Symbol , Timestamp , Value } ;
9
9
10
10
use crate :: event:: { AttributeValue , ExtensionValue } ;
11
- use crate :: message:: { BinaryDeserializer , Error , MessageAttributeValue } ;
11
+ use crate :: message:: { BinaryDeserializer , Error , MessageAttributeValue , StructuredDeserializer } ;
12
12
use crate :: Event ;
13
13
14
14
use self :: constants:: {
@@ -37,13 +37,13 @@ pub type Extensions = HashMap<String, ExtensionValue>;
37
37
/// message property field. If the value is prefixed with the CloudEvents media type
38
38
/// application/cloudevents, indicating the use of a known event format, the receiver uses
39
39
/// structured mode, otherwise it defaults to binary mode.
40
- pub struct AmqpCloudEvent {
40
+ pub struct AmqpBinding {
41
41
content_type : Option < Symbol > ,
42
42
application_properties : Option < ApplicationProperties > ,
43
43
body : AmqpBody ,
44
44
}
45
45
46
- impl AmqpCloudEvent {
46
+ impl AmqpBinding {
47
47
fn new ( ) -> Self {
48
48
Self {
49
49
content_type : None ,
@@ -55,10 +55,14 @@ impl AmqpCloudEvent {
55
55
pub fn from_binary_event ( event : Event ) -> Result < Self , Error > {
56
56
BinaryDeserializer :: deserialize_binary ( event, Self :: new ( ) )
57
57
}
58
+
59
+ pub fn from_structured_event ( event : Event ) -> Result < Self , Error > {
60
+ StructuredDeserializer :: deserialize_structured ( event, Self :: new ( ) )
61
+ }
58
62
}
59
63
60
- impl From < AmqpCloudEvent > for AmqpMessage {
61
- fn from ( event : AmqpCloudEvent ) -> Self {
64
+ impl From < AmqpBinding > for AmqpMessage {
65
+ fn from ( event : AmqpBinding ) -> Self {
62
66
let mut properties = Properties :: default ( ) ;
63
67
properties. content_type = event. content_type ;
64
68
Message {
@@ -73,7 +77,7 @@ impl From<AmqpCloudEvent> for AmqpMessage {
73
77
}
74
78
}
75
79
76
- impl From < AmqpMessage > for AmqpCloudEvent {
80
+ impl From < AmqpMessage > for AmqpBinding {
77
81
fn from ( message : AmqpMessage ) -> Self {
78
82
let content_type = message. properties . map ( |p| p. content_type ) . flatten ( ) ;
79
83
Self {
0 commit comments