@@ -25,24 +25,45 @@ mod constants;
2525///
2626/// The generic parameter can be anything that implements `Serialize` and `Deserialize` but is of
2727/// 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
2929pub type AmqpMessage = Message < Value > ;
3030
3131/// Type alias for an AMQP 1.0 Body
3232///
3333/// The generic parameter can be anything that implements `Serialize` and `Deserialize` but is of
3434/// 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
3636pub type AmqpBody = Body < Value > ;
3737
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+ /// ```
4263pub 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 ,
4667}
4768
4869impl EventMessage {
0 commit comments