@@ -25,24 +25,45 @@ mod constants;
25
25
///
26
26
/// The generic parameter can be anything that implements `Serialize` and `Deserialize` but is of
27
27
/// no importance because all CloudEvents are using the `Body::Data` as the body section type. For
28
- /// convenience, this type alias chose `Value` as the value of the generic parameter
28
+ /// convenience, this type alias chooses `Value` as the value of the generic parameter
29
29
pub type AmqpMessage = Message < Value > ;
30
30
31
31
/// Type alias for an AMQP 1.0 Body
32
32
///
33
33
/// The generic parameter can be anything that implements `Serialize` and `Deserialize` but is of
34
34
/// no importance because all CloudEvents are using the `Body::Data` as the body section type. For
35
- /// convenience, this type alias chose `Value` as the value of the generic parameter
35
+ /// convenience, this type alias chooses `Value` as the value of the generic parameter
36
36
pub type AmqpBody = Body < Value > ;
37
37
38
- /// The receiver of the event can distinguish between the two modes by inspecting the content-type
39
- /// message property field. If the value is prefixed with the CloudEvents media type
40
- /// application/cloudevents, indicating the use of a known event format, the receiver uses
41
- /// structured mode, otherwise it defaults to binary mode.
38
+ /// This struct contains the necessary fields required for AMQP 1.0 binding.
39
+ /// It provides conversion between [`Event`] and [`AmqpMessage`]
40
+ ///
41
+ /// # Examples
42
+ ///
43
+ /// ## [`Event`] -> [`AmqpMessage`] in binary content mode
44
+ ///
45
+ /// ```rust
46
+ /// let event_message = EventMessage::from_binary_event(event).unwrap();
47
+ /// let amqp_message = AmqpMessage:from(event_message);
48
+ /// ```
49
+ ///
50
+ /// ## [`Event`] -> [`AmqpMessage`] in structured content mode
51
+ ///
52
+ /// ```rust
53
+ /// let event_message = EventMessage::from_structured_event(event).unwrap();
54
+ /// let amqp_message = AmqpMessage:from(event_message);
55
+ /// ```
56
+ ///
57
+ /// ## [`AmqpMessage`] -> [`Event`]
58
+ ///
59
+ /// ```rust
60
+ /// let event_message = EventMessage::from(amqp_message);
61
+ /// let event = MessageDeserializer::into_event(event_message).unwrap();
62
+ /// ```
42
63
pub struct EventMessage {
43
- content_type : Option < Symbol > ,
44
- application_properties : Option < ApplicationProperties > ,
45
- body : AmqpBody ,
64
+ pub content_type : Option < Symbol > ,
65
+ pub application_properties : Option < ApplicationProperties > ,
66
+ pub body : AmqpBody ,
46
67
}
47
68
48
69
impl EventMessage {
0 commit comments