Skip to content

Commit d3cd1cd

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

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
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-
AmqpBinding, ATTRIBUTE_PREFIX,
16+
EventMessage, ATTRIBUTE_PREFIX,
1717
};
1818

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

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

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

src/binding/fe2o3_amqp/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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 AmqpBinding {
40+
pub struct EventMessage {
4141
content_type: Option<Symbol>,
4242
application_properties: Option<ApplicationProperties>,
4343
body: AmqpBody,
4444
}
4545

46-
impl AmqpBinding {
46+
impl EventMessage {
4747
fn new() -> Self {
4848
Self {
4949
content_type: None,
@@ -52,17 +52,19 @@ impl AmqpBinding {
5252
}
5353
}
5454

55+
/// Create an [`EventMessage`] from an event using a binary serializer
5556
pub fn from_binary_event(event: Event) -> Result<Self, Error> {
5657
BinaryDeserializer::deserialize_binary(event, Self::new())
5758
}
5859

60+
/// Create an [`EventMessage`] from an event using a structured serializer
5961
pub fn from_structured_event(event: Event) -> Result<Self, Error> {
6062
StructuredDeserializer::deserialize_structured(event, Self::new())
6163
}
6264
}
6365

64-
impl From<AmqpBinding> for AmqpMessage {
65-
fn from(event: AmqpBinding) -> Self {
66+
impl From<EventMessage> for AmqpMessage {
67+
fn from(event: EventMessage) -> Self {
6668
let mut properties = Properties::default();
6769
properties.content_type = event.content_type;
6870
Message {
@@ -77,7 +79,7 @@ impl From<AmqpBinding> for AmqpMessage {
7779
}
7880
}
7981

80-
impl From<AmqpMessage> for AmqpBinding {
82+
impl From<AmqpMessage> for EventMessage {
8183
fn from(message: AmqpMessage) -> Self {
8284
let content_type = message.properties.map(|p| p.content_type).flatten();
8385
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, AmqpBinding, ATTRIBUTE_PREFIX};
12+
use super::{AmqpBody, EventMessage, ATTRIBUTE_PREFIX};
1313

14-
impl BinarySerializer<AmqpBinding> for AmqpBinding {
14+
impl BinarySerializer<EventMessage> for EventMessage {
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<AmqpBinding> for AmqpBinding {
7979
}
8080
}
8181

82-
impl StructuredSerializer<AmqpBinding> for AmqpBinding {
82+
impl StructuredSerializer<EventMessage> for EventMessage {
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)