pub struct Flag;Expand description
A flag that is set if its key is given.
This is for bool fields that are switched on by giving their key,
like ?recursive in a query string:
- if the key is missing, the flag is
false(no#[deser(default)]is needed) - an empty value (
?recursiveor?recursive=) or null istrue - other values are booleans, strings are parsed like
lexical atoms (
?recursive=0isfalse)
The flag is serialized as boolean.
use deser::adapters::Flag;
#[derive(deser::Deserialize, deser::Serialize)]
pub struct Tree {
#[deser(as = Flag, skip_serializing_if = std::ops::Not::not)]
recursive: bool,
}Trait Implementations§
Source§impl<'de> Deserialize<'de, bool> for Flag
impl<'de> Deserialize<'de, bool> for Flag
Source§fn deserialize_atom(
slot: &mut Slot<bool, Self>,
atom: Atom<'_>,
state: &mut State,
) -> Result<(), Error>
fn deserialize_atom( slot: &mut Slot<bool, Self>, atom: Atom<'_>, state: &mut State, ) -> Result<(), Error>
Deserializes an atom into the slot. Read more
Source§fn expecting() -> Cow<'static, str>
fn expecting() -> Cow<'static, str>
Returns what the value expects, for error messages. Read more
Source§fn deserialize_into<'out>(
out: &'out mut Option<T>,
state: &mut State,
) -> SinkHandle<'out, 'de>
fn deserialize_into<'out>( out: &'out mut Option<T>, state: &mut State, ) -> SinkHandle<'out, 'de>
Creates a sink that deserializes the value into the given slot. Read more
Source§fn deserialize_borrowed_atom(
slot: &mut Slot<T, Self>,
atom: Atom<'de>,
state: &mut State,
) -> Result<(), Error>
fn deserialize_borrowed_atom( slot: &mut Slot<T, Self>, atom: Atom<'de>, state: &mut State, ) -> Result<(), Error>
Deserializes an atom that borrows from the data being deserialized
into the slot. Read more
Source§fn describe_type(d: &mut dyn Describe)
fn describe_type(d: &mut dyn Describe)
Describes the Rust shape of the type. Read more
Source§fn deserialize_update<'out>(
value: &'out mut T,
state: &mut State,
) -> SinkHandle<'out, 'de>
fn deserialize_update<'out>( value: &'out mut T, state: &mut State, ) -> SinkHandle<'out, 'de>
Creates a sink that updates an existing value. Read more
Source§impl Serialize<bool> for Flag
impl Serialize<bool> for Flag
Source§fn serialize<'a>(value: &'a bool, _state: &mut State) -> Result<Emit<'a>, Error>
fn serialize<'a>(value: &'a bool, _state: &mut State) -> Result<Emit<'a>, Error>
Serializes the value.
Source§fn finish(value: &T, state: &mut State) -> Result<(), Error>
fn finish(value: &T, state: &mut State) -> Result<(), Error>
Invoked after the serialization finished. Read more
Source§fn container_shape(value: &T) -> ContainerShape
fn container_shape(value: &T) -> ContainerShape
Returns the shape of the value if it’s a map or sequence. Read more
Auto Trait Implementations§
impl Freeze for Flag
impl RefUnwindSafe for Flag
impl Send for Flag
impl Sync for Flag
impl Unpin for Flag
impl UnsafeUnpin for Flag
impl UnwindSafe for Flag
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more