use std::{borrow::Cow, error};
use crate::{Types, datatype::DataType};
pub type FormatError = Box<dyn error::Error + Send + Sync + 'static>;
pub trait Format {
fn map_types(&'_ self, types: &Types) -> std::result::Result<Cow<'_, Types>, FormatError>;
fn map_type(
&'_ self,
types: &Types,
dt: &DataType,
) -> std::result::Result<Cow<'_, DataType>, FormatError>;
}
impl<T: Format + ?Sized> Format for &T {
fn map_types(&'_ self, types: &Types) -> std::result::Result<Cow<'_, Types>, FormatError> {
(**self).map_types(types)
}
fn map_type(
&'_ self,
types: &Types,
dt: &DataType,
) -> std::result::Result<Cow<'_, DataType>, FormatError> {
(**self).map_type(types, dt)
}
}
impl<T: Format + ?Sized> Format for Box<T> {
fn map_types(&'_ self, types: &Types) -> std::result::Result<Cow<'_, Types>, FormatError> {
(**self).map_types(types)
}
fn map_type(
&'_ self,
types: &Types,
dt: &DataType,
) -> std::result::Result<Cow<'_, DataType>, FormatError> {
(**self).map_type(types, dt)
}
}
const _: Option<&dyn Format> = None;