#![allow(unexpected_cfgs)]
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(not(feature = "std"))]
extern crate alloc;
pub(crate) mod prelude {
#[cfg(feature = "std")]
pub use std::{
borrow::Cow,
boxed::Box,
format,
rc::Rc,
string::{String, ToString},
sync::Arc,
vec::Vec,
};
#[cfg(not(feature = "std"))]
pub use alloc::{
borrow::Cow,
boxed::Box,
format,
rc::Rc,
string::{String, ToString},
sync::Arc,
vec::Vec,
};
}
pub mod attrs;
#[cfg(feature = "aws-data-api")]
pub mod aws_data_api;
pub mod builder;
pub mod common;
pub mod expr;
pub mod helpers;
pub mod traits;
pub mod transaction;
pub mod types {
pub use drizzle_types::postgres::types::*;
}
pub mod values;
#[cfg(all(test, feature = "query"))]
mod relational_sql_tests;
#[cfg(all(feature = "postgres-sync", not(feature = "tokio-postgres")))]
pub use postgres::Row;
#[cfg(feature = "tokio-postgres")]
pub use tokio_postgres::Row;
#[doc(hidden)]
pub mod driver_types {
#[cfg(all(
any(feature = "serde", feature = "query"),
feature = "postgres-sync",
not(feature = "tokio-postgres")
))]
pub use postgres::types::Json;
#[cfg(all(any(feature = "serde", feature = "query"), feature = "tokio-postgres"))]
pub use tokio_postgres::types::Json;
#[cfg(any(feature = "postgres-sync", feature = "tokio-postgres"))]
pub use bytes::BytesMut;
#[cfg(all(feature = "postgres-sync", not(feature = "tokio-postgres")))]
pub use postgres::types::{FromSql, IsNull, ToSql, Type, to_sql_checked};
#[cfg(feature = "tokio-postgres")]
pub use tokio_postgres::types::{FromSql, IsNull, ToSql, Type, to_sql_checked};
#[cfg(any(feature = "postgres-sync", feature = "tokio-postgres"))]
pub use field_decode::{FieldDecode, ViaColumn, ViaFromSql};
#[cfg(any(feature = "postgres-sync", feature = "tokio-postgres"))]
mod field_decode {
use crate::traits::DrizzlePostgresColumn;
use core::marker::PhantomData;
use drizzle_core::error::DrizzleError;
pub struct FieldDecode<T>(PhantomData<T>);
impl<T> FieldDecode<T> {
#[must_use]
pub const fn new() -> Self {
Self(PhantomData)
}
}
impl<T> Default for FieldDecode<T> {
fn default() -> Self {
Self::new()
}
}
pub trait ViaColumn<T> {
fn decode_field(&self, row: &crate::Row, idx: usize) -> Result<T, DrizzleError>;
}
impl<T: DrizzlePostgresColumn> ViaColumn<T> for &FieldDecode<T> {
fn decode_field(&self, row: &crate::Row, idx: usize) -> Result<T, DrizzleError> {
T::decode(row, idx)
}
}
pub trait ViaFromSql<T> {
fn decode_field(&self, row: &crate::Row, idx: usize) -> Result<T, DrizzleError>;
}
impl<T: for<'a> super::FromSql<'a>> ViaFromSql<T> for FieldDecode<T> {
fn decode_field(&self, row: &crate::Row, idx: usize) -> Result<T, DrizzleError> {
row.try_get::<_, T>(idx)
.map_err(|e| DrizzleError::ConversionError(e.to_string().into()))
}
}
}
}
pub use drizzle_core::ParamBind;
pub use transaction::{AccessMode, IsolationLevel, SnapshotId, TransactionConfig};