@@ -16,15 +16,12 @@ use crate::{Deserializable, Serializable};
1616#[ cfg( feature = "cplusplus" ) ]
1717use azure_core:: Result ;
1818
19+ /// An AMQP symbol.
20+ ///
21+ /// Symbols are used to identify a type of data. They are similar to strings, and represent symbolic values from a constrained domain.
1922#[ derive( Debug , PartialEq , Clone , Default , Eq ) ]
2023pub struct AmqpSymbol ( pub String ) ;
2124
22- // impl PartialEq<str> for AmqpSymbol {
23- // fn eq(&self, other: &str) -> bool {
24- // self.0.as_str() == other
25- // }
26- // }
27-
2825impl PartialEq < AmqpSymbol > for str {
2926 fn eq ( & self , other : & AmqpSymbol ) -> bool {
3027 self == other. 0 . as_str ( )
@@ -77,6 +74,7 @@ impl Borrow<str> for AmqpSymbol {
7774 }
7875}
7976
77+ /// A sequence of AMQP values
8078#[ derive( Debug , PartialEq , Clone , Default ) ]
8179pub struct AmqpList ( pub Vec < AmqpValue > ) ;
8280
@@ -132,6 +130,10 @@ impl From<std::time::SystemTime> for AmqpTimestamp {
132130 }
133131}
134132
133+ /// An ordered mapping from distinct keys to values.
134+ ///
135+ /// This is a simple implementation of a map that is backed by a vector.
136+ /// It is not intended to be used for large maps, but rather for small maps where the order of the keys is important.
135137#[ derive( Debug , PartialEq , Clone , Default ) ]
136138pub struct AmqpOrderedMap < K , V >
137139where
@@ -164,8 +166,8 @@ where
164166
165167#[ derive( Debug , PartialEq , Clone ) ]
166168pub struct AmqpDescribed {
167- pub descriptor : AmqpDescriptor ,
168- pub value : AmqpValue ,
169+ descriptor : AmqpDescriptor ,
170+ value : AmqpValue ,
169171}
170172
171173impl AmqpDescribed {
@@ -185,12 +187,18 @@ impl AmqpDescribed {
185187 }
186188}
187189
190+ /// An AMQP Composite type.
191+ /// This is a complex type that is composed of a descriptor and a value.
192+ /// The descriptor is used to identify the type of the value.
193+ /// The value is the actual value.
188194#[ derive( Debug , PartialEq , Clone ) ]
195+ #[ cfg( feature = "cplusplus" ) ]
189196pub struct AmqpComposite {
190- pub descriptor : AmqpDescriptor ,
191- pub value : AmqpList ,
197+ descriptor : AmqpDescriptor ,
198+ value : AmqpList ,
192199}
193200
201+ #[ cfg( feature = "cplusplus" ) ]
194202impl AmqpComposite {
195203 pub fn new ( descriptor : impl Into < AmqpDescriptor > , value : impl Into < AmqpList > ) -> Self {
196204 Self {
@@ -212,26 +220,48 @@ impl AmqpComposite {
212220pub enum AmqpValue {
213221 #[ default]
214222 Null ,
223+ /// A boolean (true/false) value.
215224 Boolean ( bool ) ,
225+ /// An unsigned byte value.
216226 UByte ( u8 ) ,
227+ /// An unsigned short value.
217228 UShort ( u16 ) ,
229+ /// An unsigned integer value.
218230 UInt ( u32 ) ,
231+ /// An unsigned long value.
219232 ULong ( u64 ) ,
233+ /// A signed byte value.
220234 Byte ( i8 ) ,
235+ /// A signed short value.
221236 Short ( i16 ) ,
237+ /// A signed integer value.
222238 Int ( i32 ) ,
239+ /// A signed long value.
223240 Long ( i64 ) ,
241+ /// A 32-bit floating point value.
224242 Float ( f32 ) ,
243+ /// A 64-bit floating point value.
225244 Double ( f64 ) ,
245+ /// A single Unicode character.
226246 Char ( char ) ,
247+ /// A point in time.
227248 TimeStamp ( AmqpTimestamp ) ,
249+ /// A universally unique identifier.
228250 Uuid ( Uuid ) ,
251+ /// A sequence of octets.
229252 Binary ( Vec < u8 > ) ,
253+ /// A sequence of Unicode characters.
230254 String ( String ) ,
255+ /// An AMQP Symbol.
231256 Symbol ( AmqpSymbol ) ,
257+
258+ /// An ordered list of AMQP values.
232259 List ( AmqpList ) ,
260+ /// An ordered map of AMQP values.
233261 Map ( AmqpOrderedMap < AmqpValue , AmqpValue > ) ,
262+ /// An array of AMQP values.
234263 Array ( Vec < AmqpValue > ) ,
264+ /// A described value.
235265 Described ( Box < AmqpDescribed > ) ,
236266 #[ cfg( feature = "cplusplus" ) ]
237267 Composite ( Box < AmqpComposite > ) ,
@@ -509,7 +539,6 @@ where
509539mod tests {
510540 use super :: * ;
511541 use std:: vec;
512- use Uuid ;
513542
514543 #[ test]
515544 fn test_value_create_specific ( ) {
@@ -889,4 +918,16 @@ mod tests {
889918 assert_eq ! ( unknown_value, AmqpValue :: Unknown ) ;
890919 assert_eq ! ( AmqpValue :: Unknown , unknown_value) ;
891920 }
921+
922+ #[ test]
923+ #[ cfg( feature = "cplusplus" ) ]
924+ fn amqp_composite ( ) {
925+ let composite =
926+ AmqpComposite :: new ( 0x270 , AmqpList :: from ( vec ! [ AmqpValue :: from( "String value" ) ] ) ) ;
927+ assert_eq ! ( composite. descriptor( ) , & AmqpDescriptor :: Code ( 0x270 ) ) ;
928+ assert_eq ! (
929+ composite. value( ) ,
930+ & AmqpList :: from( vec![ AmqpValue :: from( "String value" ) ] )
931+ ) ;
932+ }
892933}
0 commit comments