With Rust crate RMP RMP Crate any aproach possible pack messagepack for Tarantool field type datetime
and uuid
?
Tarantool uses the msgpack extension type with a custom internal representation of datetime and uuid. Currently it doesn't provide an api that module developers can use directly. So if you want to serialize datetime or uuid objects as tarantool compatible msgpack you'll have to implement serialization yourself.
Fortunately this is already implemented in the tarantool crate (of which I am one of the authors). There are tarantool::uuid::Uuid
& tarantool::datetime::Datetime
structs. Although Datetime is only on master branch at the moment. These structs implement serde::Serialize
& serde::Deserialize
and can be used with rmp_serde
crate to produce tarantool compatible msgpack representations.
Here's are a couple of examples:
let uuid = tarantool::uuid::Uuid::nil();
let mp = rmp_serde::to_vec(&uuid).unwrap();
// mp can be passed to tarantool
let dt: tarantool::datetime::Datetime = time_macros::datetime!(2023-05-12 10:01:42.12345 -3).into();
let mp = rmp_serde::to_vec(&dt).unwrap();
// mp can be passed to tarantool
You can also use these structs with other apis from tarantool
crate, e.g. for inserting values into a space with tarantool::space::Space::insert
.