pub mod binary;
#[macro_use]
mod refuse;
mod any;
mod kinds;
mod numbers;
mod parts;
mod rest;
mod scalars;
pub mod ser;
mod shapes;
mod skip;
mod skips;
mod unfit;
mod union;
mod why;
pub use any::{any, Any};
pub use kinds::{Kinds, Shape};
pub use numbers::*;
pub use parts::Parts;
pub use rest::{members, Unread};
pub use scalars::*;
pub use serde::de::{Deserialize, DeserializeSeed, Deserializer, IgnoredAny, MapAccess, SeqAccess};
pub use serde::de::{EnumAccess, VariantAccess};
pub use serde::ser::{Serialize, SerializeMap, SerializeTuple, Serializer};
pub use shapes::*;
pub use skip::{skip, Skip};
pub use skips::Skips;
pub use unfit::Unfit;
pub use union::{kind, Pick, Raw};
pub use why::Why;
pub fn json<'a, T>(
text: &'a str,
mut read: impl FnMut(
&mut serde_json::Deserializer<serde_json::de::StrRead<'a>>,
) -> Result<(T, Skips), Unfit>,
) -> Result<(T, Skips), Unfit> {
let mut once = || {
let mut de = serde_json::Deserializer::from_str(text);
let out = read(&mut de)?;
de.end().map_err(|e| Unfit::from_json(&e))?;
Ok(out)
};
match skip::bare(&mut once) {
(Err(_), true) => skip::whole(once),
(done, _) => done,
}
}
pub fn root<T, E>(read: impl FnOnce() -> Result<T, E>, name: &str) -> Result<(T, Skips), Unfit> {
let _previous = unfit::Previous::empty();
skips::collect(
|| {
read().map_err(|_| match skip::bare_failed() {
true => Unfit::absent(),
false => Unfit::raised().map_or_else(
|| Unfit::other("a value the deserializer can't read").model(name),
|unfit| unfit.model(name),
),
})
},
|u| u.model(name),
)
}
#[cfg(test)]
mod binary_tests;
#[cfg(test)]
mod skip_tests;
#[cfg(test)]
mod tests;
#[cfg(test)]
mod tuple_tests;