use serde::Serialize;
use std::fmt::Debug;
use crate::transform::Transform;
pub trait TryToWrappedWith<T>: Debug + Clone + Serialize
where
T: Transform,
{
type Wrapper;
type Error: Debug;
fn try_to_wrapped_with(self, transform: &T, options: &T::Options) -> Result<Self::Wrapper, Self::Error>;
}
pub trait TryWrapDataWith<D, T>: Sized
where
T: Transform,
D: TryToWrappedWith<T>,
{
fn try_wrap_data_with(data: D, transform: &T, options: &T::Options) -> Result<Self, D::Error>;
}
impl<D, T> TryWrapDataWith<D, T> for <D as TryToWrappedWith<T>>::Wrapper
where
T: Transform,
D: TryToWrappedWith<T>,
{
fn try_wrap_data_with(data: D, transform: &T, options: &<T as Transform>::Options) -> Result<Self, D::Error> {
data.try_to_wrapped_with(transform, options)
}
}