use crate::parsely_write::ParselyWrite;
pub type ParselyResult<T> = anyhow::Result<T>;
pub trait IntoWritableParselyResult<T, B> {
fn into_writable_parsely_result(self) -> ParselyResult<T>;
}
impl<T, B> IntoWritableParselyResult<T, B> for T
where
T: ParselyWrite<B>,
{
fn into_writable_parsely_result(self) -> ParselyResult<T> {
Ok(self)
}
}
impl<T, E, B> IntoWritableParselyResult<T, B> for Result<T, E>
where
E: Into<anyhow::Error>,
{
fn into_writable_parsely_result(self) -> ParselyResult<T> {
self.map_err(Into::into)
}
}
pub trait IntoParselyResult<T> {
fn into_parsely_result(self) -> ParselyResult<T>;
}
impl<T> IntoParselyResult<T> for T {
fn into_parsely_result(self) -> ParselyResult<T> {
Ok(self)
}
}
impl<T, E> IntoParselyResult<T> for Result<T, E>
where
E: Into<anyhow::Error>,
{
fn into_parsely_result(self) -> ParselyResult<T> {
self.map_err(Into::into)
}
}