#[cfg(feature = "deserialize")]
#[macro_export]
macro_rules! options {
( $( $tt:tt )* ) => {{
let mut opt = $crate::Options::default();
$crate::__serde_saphyr_options_apply!(opt, $( $tt )*);
opt
}};
}
#[cfg(not(feature = "deserialize"))]
#[macro_export]
macro_rules! options {
( $( $tt:tt )* ) => {
compile_error!("serde-saphyr `options!` requires feature `deserialize`");
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __serde_saphyr_options_apply {
($opt:ident,) => {};
($opt:ident) => {};
($opt:ident, require_indent : $crate::RequireIndent::Divisible(0) $(, $($rest:tt)*)? ) => {{
compile_error!("`Divisible` indentation must be non-zero");
}};
($opt:ident, require_indent : $value:expr $(, $($rest:tt)*)? ) => {{
{
let val = $value;
if let $crate::RequireIndent::Divisible(n) = &val {
assert!(*n != 0, "`Divisible` indentation must be non-zero");
}
#[allow(deprecated)]
{
$opt.require_indent = val;
}
}
$( $crate::__serde_saphyr_options_apply!($opt, $($rest)*); )?
}};
($opt:ident, $field:ident : $value:expr $(, $($rest:tt)*)? ) => {{
#[allow(deprecated)]
{
$opt.$field = $value;
}
$( $crate::__serde_saphyr_options_apply!($opt, $($rest)*); )?
}};
}
#[cfg(feature = "serialize")]
#[macro_export]
macro_rules! ser_options {
( $( $tt:tt )* ) => {{
let mut opt = $crate::SerializerOptions::default();
$crate::__serde_saphyr_serializer_options_apply!(opt, $( $tt )*);
opt
}};
}
#[cfg(not(feature = "serialize"))]
#[macro_export]
macro_rules! ser_options {
( $( $tt:tt )* ) => {
compile_error!("serde-saphyr `ser_options!` requires feature `serialize`");
};
}
#[cfg(feature = "deserialize")]
#[macro_export]
macro_rules! budget {
( $( $field:ident : $value:expr ),* $(,)? ) => {{
let mut b = $crate::Budget::default();
$(
#[allow(deprecated)]
{
b.$field = $value;
}
)*
Some(b)
}};
}
#[cfg(not(feature = "deserialize"))]
#[macro_export]
macro_rules! budget {
( $( $field:ident : $value:expr ),* $(,)? ) => {
compile_error!("serde-saphyr `budget!` requires feature `deserialize`");
};
}
#[macro_export]
macro_rules! render_options {
( $( $field:ident : $value:expr ),* $(,)? ) => {{
let mut opt = $crate::RenderOptions::default();
$(
{
opt.$field = $value;
}
)*
opt
}};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __serde_saphyr_serializer_options_apply {
($opt:ident,) => {};
($opt:ident) => {};
($opt:ident, indent_step : $value:literal $(, $($rest:tt)*)? ) => {{
const _: () = {
if !($value > 0 && $value < 65536) {
panic!("`indent_step` must be in the range 1..=65535");
}
};
#[allow(deprecated)]
{
$opt.indent_step = $value;
}
$( $crate::__serde_saphyr_serializer_options_apply!($opt, $($rest)*); )?
}};
($opt:ident, indent_step : $value:expr $(, $($rest:tt)*)? ) => {{
#[allow(deprecated)]
{
$opt.indent_step = $value;
}
$( $crate::__serde_saphyr_serializer_options_apply!($opt, $($rest)*); )?
}};
($opt:ident, $field:ident : $value:expr $(, $($rest:tt)*)? ) => {{
#[allow(deprecated)]
{
$opt.$field = $value;
}
$( $crate::__serde_saphyr_serializer_options_apply!($opt, $($rest)*); )?
}};
}