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