#[allow(missing_docs, non_camel_case_types)]
pub mod tag {
pub struct Boolean;
pub struct Int<const BYTES: u8>;
pub struct UInt<const BYTES: u8>;
pub struct I8;
pub struct I16;
pub struct I32;
pub struct I64;
pub struct U8;
pub struct U16;
pub struct U32;
pub struct U64;
pub struct F32;
pub struct F64;
pub struct Text;
pub struct VarChar;
pub struct Json;
pub struct Jsonb;
pub struct Binary;
pub struct Blob;
pub struct Timestamp;
pub struct Date;
pub struct Time;
pub struct DateTime;
}
#[diagnostic::on_unimplemented(
message = "field type `{Self}` is not compatible with the requested column storage `{Storage}`",
label = "incompatible Rust type for `#[column(type = ...)]`",
note = "see `toasty::codegen_support::storage` for the compatibility table"
)]
pub trait CompatibleWith<Storage> {}
pub trait IntegerStorage {}
impl IntegerStorage for tag::I8 {}
impl IntegerStorage for tag::I16 {}
impl IntegerStorage for tag::I32 {}
impl IntegerStorage for tag::I64 {}
impl IntegerStorage for tag::U8 {}
impl IntegerStorage for tag::U16 {}
impl IntegerStorage for tag::U32 {}
impl IntegerStorage for tag::U64 {}
impl<const BYTES: u8> IntegerStorage for tag::Int<BYTES> {}
impl<const BYTES: u8> IntegerStorage for tag::UInt<BYTES> {}
impl<T, S> CompatibleWith<S> for Option<T> where T: CompatibleWith<S> {}
impl<T, S> CompatibleWith<S> for crate::Deferred<T> where T: CompatibleWith<S> {}
impl<T, S> CompatibleWith<S> for Box<T> where T: CompatibleWith<S> {}
impl<T, S> CompatibleWith<S> for std::rc::Rc<T> where T: CompatibleWith<S> {}
impl<T, S> CompatibleWith<S> for std::sync::Arc<T> where T: CompatibleWith<S> {}
macro_rules! impl_integer_enum_collection_compat {
($($storage:ty),* $(,)?) => {
$(
impl<T> CompatibleWith<$storage> for Vec<T>
where
T: crate::schema::Embed
+ crate::schema::Scalar
+ CompatibleWith<$storage>,
{}
)*
};
}
impl_integer_enum_collection_compat!(
tag::I8,
tag::I16,
tag::I32,
tag::I64,
tag::U8,
tag::U16,
tag::U32,
tag::U64,
);
impl<T, const BYTES: u8> CompatibleWith<tag::Int<BYTES>> for Vec<T> where
T: crate::schema::Embed + crate::schema::Scalar + CompatibleWith<tag::Int<BYTES>>
{
}
impl<T, const BYTES: u8> CompatibleWith<tag::UInt<BYTES>> for Vec<T> where
T: crate::schema::Embed + crate::schema::Scalar + CompatibleWith<tag::UInt<BYTES>>
{
}
impl CompatibleWith<tag::Boolean> for bool {}
impl CompatibleWith<tag::I8> for i8 {}
impl CompatibleWith<tag::I16> for i16 {}
impl CompatibleWith<tag::I32> for i32 {}
impl CompatibleWith<tag::I64> for i64 {}
impl CompatibleWith<tag::U8> for u8 {}
impl CompatibleWith<tag::U16> for u16 {}
impl CompatibleWith<tag::U32> for u32 {}
impl CompatibleWith<tag::U64> for u64 {}
macro_rules! impl_custom_integer_compat {
($storage:ident => $($ty:ty),* $(,)?) => {
$(
#[diagnostic::do_not_recommend]
impl<const BYTES: u8> CompatibleWith<tag::$storage<BYTES>> for $ty {}
)*
};
}
impl_custom_integer_compat!(Int => i8, i16, i32, i64);
impl_custom_integer_compat!(UInt => u8, u16, u32, u64);
impl CompatibleWith<tag::F32> for f32 {}
impl CompatibleWith<tag::F64> for f64 {}
impl CompatibleWith<tag::F32> for f64 {}
impl CompatibleWith<tag::F64> for f32 {}
impl CompatibleWith<tag::Text> for String {}
impl CompatibleWith<tag::VarChar> for String {}
#[cfg(feature = "serde")]
impl<T> CompatibleWith<tag::Text> for crate::Json<T> {}
#[cfg(feature = "serde")]
impl<T> CompatibleWith<tag::VarChar> for crate::Json<T> {}
#[cfg(feature = "serde")]
impl<T> CompatibleWith<tag::Json> for crate::Json<T> {}
#[cfg(feature = "serde")]
impl<T> CompatibleWith<tag::Jsonb> for crate::Json<T> {}
#[cfg(feature = "serde")]
impl CompatibleWith<tag::Text> for serde_json::Value {}
#[cfg(feature = "serde")]
impl CompatibleWith<tag::VarChar> for serde_json::Value {}
#[cfg(feature = "serde")]
impl CompatibleWith<tag::Json> for serde_json::Value {}
#[cfg(feature = "serde")]
impl CompatibleWith<tag::Jsonb> for serde_json::Value {}
impl CompatibleWith<tag::Binary> for Vec<u8> {}
impl CompatibleWith<tag::Blob> for Vec<u8> {}
impl CompatibleWith<tag::Text> for uuid::Uuid {}
impl CompatibleWith<tag::VarChar> for uuid::Uuid {}
impl CompatibleWith<tag::Blob> for uuid::Uuid {}
impl CompatibleWith<tag::Binary> for uuid::Uuid {}
#[cfg(feature = "rust_decimal")]
impl CompatibleWith<tag::Text> for rust_decimal::Decimal {}
#[cfg(feature = "rust_decimal")]
impl CompatibleWith<tag::VarChar> for rust_decimal::Decimal {}
#[cfg(feature = "bigdecimal")]
impl CompatibleWith<tag::Text> for bigdecimal::BigDecimal {}
#[cfg(feature = "bigdecimal")]
impl CompatibleWith<tag::VarChar> for bigdecimal::BigDecimal {}
#[cfg(feature = "jiff")]
mod jiff_impls {
use super::{CompatibleWith, tag};
impl CompatibleWith<tag::Timestamp> for jiff::Timestamp {}
impl CompatibleWith<tag::Date> for jiff::civil::Date {}
impl CompatibleWith<tag::Time> for jiff::civil::Time {}
impl CompatibleWith<tag::DateTime> for jiff::civil::DateTime {}
impl CompatibleWith<tag::Text> for jiff::Timestamp {}
impl CompatibleWith<tag::VarChar> for jiff::Timestamp {}
impl CompatibleWith<tag::Text> for jiff::civil::Date {}
impl CompatibleWith<tag::VarChar> for jiff::civil::Date {}
impl CompatibleWith<tag::Text> for jiff::civil::Time {}
impl CompatibleWith<tag::VarChar> for jiff::civil::Time {}
impl CompatibleWith<tag::Text> for jiff::civil::DateTime {}
impl CompatibleWith<tag::VarChar> for jiff::civil::DateTime {}
}