use serde::Deserialize;
use crate::MultiValues;
use super::WireDataTypeV1;
macro_rules! define_collection_wire_owned {
(
$(
(
[$($cfg:meta),*],
[$($scalar_attr:meta),*],
[$($collection_attr:meta),*],
$variant:ident,
$type:ty,
$tag:literal
)
),+ $(,)?
) => {
#[derive(Deserialize)]
pub(in crate::value_wire) enum CollectionWireOwned {
#[serde(rename = "unset")]
Unset(
/// Declared element type of the unset collection.
WireDataTypeV1,
),
$(
$(#[$cfg])*
$(#[$collection_attr])*
#[doc = concat!("Owned `", $tag, "` collection payload.")]
#[serde(rename = $tag)]
$variant(
#[doc = concat!("Stored `", $tag, "` collection values.")]
Vec<$type>,
),
)+
}
impl From<CollectionWireOwned> for MultiValues {
fn from(values: CollectionWireOwned) -> Self {
match values {
CollectionWireOwned::Unset(data_type) => Self::new_unset(data_type.into()),
$(
$(#[$cfg])*
CollectionWireOwned::$variant(values) => Self::$variant(values),
)+
}
}
}
};
}
for_each_wire_type!(define_collection_wire_owned);