fn eq()

in sdk/core/azure_core_amqp/src/fe2o3/value.rs [334:406]


    fn eq(&self, other: &AmqpValue) -> bool {
        match other {
            AmqpValue::Null => self == &fe2o3_amqp_types::primitives::Value::Null,
            AmqpValue::Boolean(b) => self == &fe2o3_amqp_types::primitives::Value::Bool(*b),
            AmqpValue::UByte(b) => self == &fe2o3_amqp_types::primitives::Value::Ubyte(*b),
            AmqpValue::UShort(s) => self == &fe2o3_amqp_types::primitives::Value::Ushort(*s),
            AmqpValue::UInt(i) => self == &fe2o3_amqp_types::primitives::Value::Uint(*i),
            AmqpValue::ULong(l) => self == &fe2o3_amqp_types::primitives::Value::Ulong(*l),
            AmqpValue::Byte(b) => self == &fe2o3_amqp_types::primitives::Value::Byte(*b),
            AmqpValue::Short(s) => self == &fe2o3_amqp_types::primitives::Value::Short(*s),
            AmqpValue::Int(i) => self == &fe2o3_amqp_types::primitives::Value::Int(*i),
            AmqpValue::Long(l) => self == &fe2o3_amqp_types::primitives::Value::Long(*l),
            AmqpValue::Float(f) => self == &fe2o3_amqp_types::primitives::Value::Float((*f).into()),
            AmqpValue::Double(d) => {
                self == &fe2o3_amqp_types::primitives::Value::Double((*d).into())
            }
            AmqpValue::Char(c) => self == &fe2o3_amqp_types::primitives::Value::Char(*c),
            AmqpValue::TimeStamp(t) => {
                if let Some(t) = t.0 {
                    let t: u64 = t
                        .duration_since(UNIX_EPOCH)
                        .expect("Could not convert timestamp into unix epoch")
                        .as_millis() as u64;
                    self == &fe2o3_amqp_types::primitives::Value::Timestamp(
                        Timestamp::from_milliseconds(t as i64),
                    )
                } else {
                    self == &fe2o3_amqp_types::primitives::Value::Timestamp(
                        Timestamp::from_milliseconds(CE_ZERO_MILLISECONDS),
                    )
                }
            }
            AmqpValue::Uuid(u) => self == &fe2o3_amqp_types::primitives::Value::Uuid((*u).into()),
            AmqpValue::Binary(b) => {
                self == &fe2o3_amqp_types::primitives::Value::Binary(ByteBuf::from(b.clone()))
            }
            AmqpValue::String(s) => self == &fe2o3_amqp_types::primitives::Value::String(s.clone()),
            AmqpValue::Symbol(s) => {
                self == &fe2o3_amqp_types::primitives::Value::Symbol((*s).clone().into())
            }
            AmqpValue::List(l) => {
                let l: Vec<fe2o3_amqp_types::primitives::Value> =
                    l.0.iter().map(|v| v.clone().into()).collect();
                self == &fe2o3_amqp_types::primitives::Value::List(l)
            }
            AmqpValue::Map(m) => {
                let m: fe2o3_amqp_types::primitives::OrderedMap<
                    fe2o3_amqp_types::primitives::Value,
                    fe2o3_amqp_types::primitives::Value,
                > = m.clone().into();
                self == &fe2o3_amqp_types::primitives::Value::Map(m)
            }
            AmqpValue::Array(a) => match self {
                fe2o3_amqp_types::primitives::Value::Array(b) => {
                    a.iter().zip(b.iter()).all(|(a, b)| a == b)
                }
                _ => false,
            },
            AmqpValue::Described(d) => match self {
                fe2o3_amqp_types::primitives::Value::Described(a) => **d == **a,
                _ => false,
            },

            // An AMQP Composite type is essentially a Described type with a specific descriptor which
            // indicates which AMQP performative it is.
            //
            // Iron Oxide does not directly support Composite types (they're handled via macros), so we always return false.
            #[cfg(feature = "cplusplus")]
            AmqpValue::Composite(_) => false,

            AmqpValue::Unknown => todo!(),
        }
    }