minghuaw / fe2o3-amqp

A rust implementation of the AMQP1.0 protocol based on serde and tokio.
MIT License
64 stars 7 forks source link

serde_amqp panic determining serialized size of AmqpDescribed containing a List with a Timestamp in the List #279

Closed LarryOsterman closed 2 months ago

LarryOsterman commented 3 months ago

Getting the size of an AMQP Described value containing a list containing a Timestamp value panics with "unreachable!" in size_ser.rs:498:32.

Simple repro:

    let timestamp = fe2o3_amqp_types::primitives::Timestamp::from_milliseconds(12345);
    let mut list = fe2o3_amqp_types::primitives::List::new();
    list.push(fe2o3_amqp_types::primitives::Value::Timestamp(timestamp));

    let described = serde_amqp::described::Described {
        descriptor: serde_amqp::descriptor::Descriptor::Code(0x73),
        value: fe2o3_amqp_types::primitives::Value::List(list),
    };

    let value = fe2o3_amqp_types::primitives::Value::Described(Box::new(described));

    let size_result = serde_amqp::size_ser::serialized_size(&value);
    assert!(size_result.is_ok());

Note that the corresponding to_vec call works just fine:

    let timestamp = fe2o3_amqp_types::primitives::Timestamp::from_milliseconds(12345);
    let mut list = fe2o3_amqp_types::primitives::List::new();
    list.push(fe2o3_amqp_types::primitives::Value::Timestamp(timestamp));

    let described = serde_amqp::described::Described {
        descriptor: serde_amqp::descriptor::Descriptor::Code(0x73),
        value: fe2o3_amqp_types::primitives::Value::List(list),
    };

    let value = fe2o3_amqp_types::primitives::Value::Described(Box::new(described));

    let vec_result = serde_amqp::ser::to_vec(&value);
    assert!(vec_result.is_ok());
minghuaw commented 3 months ago

Should be fixed in 0.12.2 #280