use serde::Deserialize;
use super::WireDataTypeV1;
use crate::MultiValues;
macro_rules! define_collection_wire_owned {
(
$($arg:expr),*;
$(
(
[$($cfg:meta),*],
$variant:ident,
$type:ty,
$_data_type:expr,
$_materialization:ident,
$_json_class:ident,
$_number_projection:ident,
$_value_doc:literal,
$_multi_doc:literal,
[$($scalar_attr:meta),*],
[$($collection_attr:meta),*],
$tag:literal,
$_wire_preflight:ident
)
),+ $(,)?
) => {
#[derive(Deserialize)]
pub(in crate::value_wire) enum CollectionWireOwned {
#[serde(rename = "unset")]
Unset(
/// Declared element type of the unset collection.
WireDataTypeV1,
),
$(
#[doc = concat!("Owned `", $tag, "` collection payload.")]
$(#[$cfg])*
$(#[$collection_attr])*
#[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_value_type!(define_collection_wire_owned);