Skip to content

Commit 0c9a92a

Browse files
committed
renamed to AmqpBinding
Signed-off-by: minghuaw <[email protected]>
1 parent f34bbe5 commit 0c9a92a

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

src/binding/fe2o3_amqp/deserializer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use crate::{
1313

1414
use super::{
1515
constants::{prefixed, DATACONTENTTYPE},
16-
AmqpCloudEvent, ATTRIBUTE_PREFIX,
16+
AmqpBinding, ATTRIBUTE_PREFIX,
1717
};
1818

19-
impl BinaryDeserializer for AmqpCloudEvent {
19+
impl BinaryDeserializer for AmqpBinding {
2020
fn deserialize_binary<R: Sized, V: BinarySerializer<R>>(
2121
mut self,
2222
mut serializer: V,
@@ -74,7 +74,7 @@ impl BinaryDeserializer for AmqpCloudEvent {
7474
}
7575
}
7676

77-
impl StructuredDeserializer for AmqpCloudEvent {
77+
impl StructuredDeserializer for AmqpBinding {
7878
fn deserialize_structured<R: Sized, V: StructuredSerializer<R>>(
7979
self,
8080
serializer: V,
@@ -89,7 +89,7 @@ impl StructuredDeserializer for AmqpCloudEvent {
8989
}
9090
}
9191

92-
impl MessageDeserializer for AmqpCloudEvent {
92+
impl MessageDeserializer for AmqpBinding {
9393
fn encoding(&self) -> Encoding {
9494
match self
9595
.content_type

src/binding/fe2o3_amqp/mod.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use fe2o3_amqp_lib::types::messaging::{ApplicationProperties, Body, Message, Pro
88
use fe2o3_amqp_lib::types::primitives::{Binary, SimpleValue, Symbol, Timestamp, Value};
99

1010
use crate::event::{AttributeValue, ExtensionValue};
11-
use crate::message::{BinaryDeserializer, Error, MessageAttributeValue};
11+
use crate::message::{BinaryDeserializer, Error, MessageAttributeValue, StructuredDeserializer};
1212
use crate::Event;
1313

1414
use self::constants::{
@@ -37,13 +37,13 @@ pub type Extensions = HashMap<String, ExtensionValue>;
3737
/// message property field. If the value is prefixed with the CloudEvents media type
3838
/// application/cloudevents, indicating the use of a known event format, the receiver uses
3939
/// structured mode, otherwise it defaults to binary mode.
40-
pub struct AmqpCloudEvent {
40+
pub struct AmqpBinding {
4141
content_type: Option<Symbol>,
4242
application_properties: Option<ApplicationProperties>,
4343
body: AmqpBody,
4444
}
4545

46-
impl AmqpCloudEvent {
46+
impl AmqpBinding {
4747
fn new() -> Self {
4848
Self {
4949
content_type: None,
@@ -55,10 +55,14 @@ impl AmqpCloudEvent {
5555
pub fn from_binary_event(event: Event) -> Result<Self, Error> {
5656
BinaryDeserializer::deserialize_binary(event, Self::new())
5757
}
58+
59+
pub fn from_structured_event(event: Event) -> Result<Self, Error> {
60+
StructuredDeserializer::deserialize_structured(event, Self::new())
61+
}
5862
}
5963

60-
impl From<AmqpCloudEvent> for AmqpMessage {
61-
fn from(event: AmqpCloudEvent) -> Self {
64+
impl From<AmqpBinding> for AmqpMessage {
65+
fn from(event: AmqpBinding) -> Self {
6266
let mut properties = Properties::default();
6367
properties.content_type = event.content_type;
6468
Message {
@@ -73,7 +77,7 @@ impl From<AmqpCloudEvent> for AmqpMessage {
7377
}
7478
}
7579

76-
impl From<AmqpMessage> for AmqpCloudEvent {
80+
impl From<AmqpMessage> for AmqpBinding {
7781
fn from(message: AmqpMessage) -> Self {
7882
let content_type = message.properties.map(|p| p.content_type).flatten();
7983
Self {

src/binding/fe2o3_amqp/serializer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use crate::{
99
};
1010

1111
use super::constants::DATACONTENTTYPE;
12-
use super::{AmqpBody, AmqpCloudEvent, ATTRIBUTE_PREFIX};
12+
use super::{AmqpBody, AmqpBinding, ATTRIBUTE_PREFIX};
1313

14-
impl BinarySerializer<AmqpCloudEvent> for AmqpCloudEvent {
14+
impl BinarySerializer<AmqpBinding> for AmqpBinding {
1515
fn set_spec_version(mut self, spec_version: SpecVersion) -> crate::message::Result<Self> {
1616
let key = String::from("cloudEvents:specversion");
1717
let value = String::from(spec_version.as_str());
@@ -79,7 +79,7 @@ impl BinarySerializer<AmqpCloudEvent> for AmqpCloudEvent {
7979
}
8080
}
8181

82-
impl StructuredSerializer<AmqpCloudEvent> for AmqpCloudEvent {
82+
impl StructuredSerializer<AmqpBinding> for AmqpBinding {
8383
fn set_structured_event(mut self, bytes: Vec<u8>) -> crate::message::Result<Self> {
8484
self.content_type = Some(Symbol::from("application/cloudevents+json; charset=utf-8"));
8585
self.body = AmqpBody::Data(AmqpData(Binary::from(bytes)));

0 commit comments

Comments
 (0)