use crate::{DeserializeValue, Key, Value};
use nonempty::NonEmpty;
#[derive(miette::Diagnostic, thiserror::Error, Debug, Clone, Eq, PartialEq, Hash, Copy)]
#[error("!")]
pub struct InfallibleError;
impl crate::Error for InfallibleError {
fn expected_type() -> std::borrow::Cow<'static, str> {
"!".into()
}
}
impl<'de> DeserializeValue<'de> for toml::de::DeValue<'de> {
type Error = InfallibleError;
fn deserialize_value<'k>(
_key: Key<'k>,
value: Value<'de>,
) -> Result<Self, crate::DeserializeErrors<Self, NonEmpty<Self::Error>>> {
Ok(value.into_inner())
}
}
impl<T> DeserializeValue<'_> for std::marker::PhantomData<T> {
type Error = InfallibleError;
fn deserialize_value(
_key: Key,
_value: Value,
) -> Result<Self, crate::DeserializeErrors<Self, NonEmpty<Self::Error>>> {
Ok(Self)
}
}