use serde::Serialize;
use super::WireDataTypeV1;
use crate::MultiValues;
use crate::multi_values::MultiValuesRepr;
macro_rules! define_collection_wire_ref {
(
$($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(Clone, Copy, Serialize)]
pub(in crate::value_wire) enum CollectionWireRef<'a> {
#[serde(rename = "unset")]
Unset(
/// Declared element type of the unset collection.
WireDataTypeV1,
),
$(
#[doc = concat!("Borrowed `", $tag, "` collection payload.")]
$(#[$cfg])*
$(#[$collection_attr])*
#[serde(rename = $tag)]
$variant(
#[doc = concat!("Stored `", $tag, "` collection values.")]
&'a Vec<$type>,
),
)+
}
impl<'a> From<&'a MultiValues> for CollectionWireRef<'a> {
fn from(values: &'a MultiValues) -> Self {
match &values.repr {
MultiValuesRepr::Unset(data_type) => Self::Unset((*data_type).into()),
$(
$(#[$cfg])*
MultiValuesRepr::$variant(values) => Self::$variant(values),
)+
}
}
}
};
}
for_each_value_type!(define_collection_wire_ref);