#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Missing {
String(::std::string::String),
Integer(i32),
Double(f64),
Bool(bool),
}
impl ::serde::Serialize for Missing {
fn serialize<S__: ::serde::Serializer>(
&self,
serializer: S__,
) -> ::core::result::Result<S__::Ok, S__::Error> {
match self {
Self::String(value) => ::serde::Serialize::serialize(value, serializer),
Self::Integer(value) => ::serde::Serialize::serialize(value, serializer),
Self::Double(value) => ::serde::Serialize::serialize(value, serializer),
Self::Bool(value) => ::serde::Serialize::serialize(value, serializer),
}
}
}
impl<'de> ::serde::Deserialize<'de> for Missing {
fn deserialize<D__: ::serde::Deserializer<'de>>(
deserializer: D__,
) -> ::core::result::Result<Self, D__::Error> {
struct Shape;
impl<'de> ::oxsearch_core::__private::ByKind<'de> for Shape {
type Value = Missing;
const EXPECTING: &'static str = "Missing: boolean or number or string";
fn visit<V__: ::serde::Deserializer<'de>>(
self,
kind: ::oxsearch_core::__private::Kind,
value: V__,
) -> ::core::result::Result<Self::Value, V__::Error> {
match kind {
::oxsearch_core::__private::Kind::Bool => {
<bool as ::serde::Deserialize>::deserialize(value).map(Missing::Bool)
}
::oxsearch_core::__private::Kind::Number => {
let json: ::serde_json::Value = ::serde::Deserialize::deserialize(value)?;
if let ::core::result::Result::Ok(found) =
::oxsearch_core::__private::from_value::<i32, V__::Error>(json.clone())
{
return ::core::result::Result::Ok(Missing::Integer(found));
}
::oxsearch_core::__private::from_value(json).map(Missing::Double)
}
::oxsearch_core::__private::Kind::String => {
<::std::string::String as ::serde::Deserialize>::deserialize(value)
.map(Missing::String)
}
_ => ::core::result::Result::Err(<V__::Error as ::serde::de::Error>::custom(
format_args!("Missing can't be {kind:?}"),
)),
}
}
}
::oxsearch_core::__private::deserialize_by_kind(deserializer, Shape)
}
}
impl ::core::convert::From<::std::string::String> for Missing {
fn from(value: ::std::string::String) -> Self {
Self::String(value)
}
}
impl ::core::convert::From<i32> for Missing {
fn from(value: i32) -> Self {
Self::Integer(value)
}
}
impl ::core::convert::From<f64> for Missing {
fn from(value: f64) -> Self {
Self::Double(value)
}
}
impl ::core::convert::From<bool> for Missing {
fn from(value: bool) -> Self {
Self::Bool(value)
}
}
impl ::core::convert::From<&str> for Missing {
fn from(value: &str) -> Self {
Self::String(::std::borrow::ToOwned::to_owned(value))
}
}