pub use self::error::*;
pub use self::index::*;
use crate::internal::any::{AnyDecode, AnyRow, AnyType};
use crate::row::get::try_get;
mod error;
mod get;
mod index;
pub struct Row(pub(crate) AnyRow);
impl Row {
pub fn get<'r, 'i, T>(&'r self, index: impl Into<RowIndex<'i>>) -> Result<T, RowError<'i>>
where
T: Decode<'r>,
{
match &self.0 {
#[cfg(feature = "postgres")]
AnyRow::Postgres(row) => try_get(row, index.into()),
#[cfg(feature = "sqlite")]
AnyRow::Sqlite(row) => try_get(row, index.into()),
}
}
}
pub trait Decode<'r>: AnyType + AnyDecode<'r> {}
impl<'r, T: AnyType + AnyDecode<'r>> Decode<'r> for T {}
pub trait DecodeOwned: for<'r> Decode<'r> {}
impl<T: for<'r> Decode<'r>> DecodeOwned for T {}