macro_rules! impl_get_set {
($ty_name:ident, $name:ident, $with:ident, $without:ident $(, $extra_doc:literal)? $(,)?) => {
#[doc = concat!("Returns whether the \"", stringify!($name), "\" refresh kind is enabled.")]
$(#[doc = concat!("\n", $extra_doc, "\n")])?
pub fn $name(&self) -> bool {
self.$name
}
#[doc = concat!("Enables the \"", stringify!($name), "\" refresh kind.")]
#[must_use]
pub fn $with(mut self) -> Self {
self.$name = true;
self
}
#[doc = concat!("Disables the \"", stringify!($name), "\" refresh kind.")]
#[must_use]
pub fn $without(mut self) -> Self {
self.$name = false;
self
}
};
($ty_name:ident, $name:ident, $with:ident, $without:ident, UpdateKind $(, $extra_doc:literal)? $(,)?) => {
#[doc = concat!("Returns the update strategy for the \"", stringify!($name), "\" refresh kind.")]
$(#[doc = concat!("\n", $extra_doc, "\n")])?
pub fn $name(&self) -> UpdateKind {
self.$name
}
#[doc = concat!("Sets the update strategy for the \"", stringify!($name), "\" refresh kind.")]
#[must_use]
pub fn $with(mut self, kind: UpdateKind) -> Self {
self.$name = kind;
self
}
#[doc = concat!("Resets the \"", stringify!($name), "\" update strategy to [`UpdateKind::Never`].")]
#[must_use]
pub fn $without(mut self) -> Self {
self.$name = UpdateKind::Never;
self
}
};
($ty_name:ident, $name:ident, $with:ident, $without:ident, $typ:ty $(,)?) => {
#[doc = concat!("Returns the \"", stringify!($name), "\" refresh kind, if set.")]
pub fn $name(&self) -> Option<$typ> {
self.$name
}
#[doc = concat!("Sets the \"", stringify!($name), "\" refresh kind.")]
#[must_use]
pub fn $with(mut self, kind: $typ) -> Self {
self.$name = Some(kind);
self
}
#[doc = concat!("Unsets the \"", stringify!($name), "\" refresh kind.")]
#[must_use]
pub fn $without(mut self) -> Self {
self.$name = None;
self
}
};
}
pub(crate) use impl_get_set;