pub trait Entity {
type PrimaryKey<'a>;
Show 19 methods
// Required methods
fn table_ref() -> &'static TableRef;
fn columns() -> &'static [ColumnDef];
fn primary_key_def() -> impl ExactSizeIterator<Item = &'static ColumnDef>;
fn unique_defs( ) -> impl ExactSizeIterator<Item = impl ExactSizeIterator<Item = &'static ColumnDef>>;
fn from_row(row: RowLabeled) -> Result<Self>
where Self: Sized;
fn create_table<Exec: Executor>(
executor: &mut Exec,
if_not_exists: bool,
create_schema: bool,
) -> impl Future<Output = Result<()>> + Send;
fn drop_table<Exec: Executor>(
executor: &mut Exec,
if_exists: bool,
drop_schema: bool,
) -> impl Future<Output = Result<()>> + Send;
fn insert_one<Exec: Executor, E: Entity>(
executor: &mut Exec,
entity: &E,
) -> impl Future<Output = Result<RowsAffected>> + Send;
fn insert_many<'a, Exec, It>(
executor: &mut Exec,
items: It,
) -> impl Future<Output = Result<RowsAffected>> + Send
where Self: 'a,
Exec: Executor,
It: IntoIterator<Item = &'a Self> + Send;
fn find_pk<Exec: Executor>(
executor: &mut Exec,
primary_key: &Self::PrimaryKey<'_>,
) -> impl Future<Output = Result<Option<Self>>> + Send
where Self: Sized;
fn find_many<Exec: Executor, Expr: Expression>(
executor: &mut Exec,
condition: &Expr,
limit: Option<u32>,
) -> impl Stream<Item = Result<Self>> + Send
where Self: Sized;
fn delete_one<Exec: Executor>(
executor: &mut Exec,
primary_key: Self::PrimaryKey<'_>,
) -> impl Future<Output = Result<RowsAffected>> + Send
where Self: Sized;
fn delete_many<Exec: Executor, Expr: Expression>(
executor: &mut Exec,
condition: &Expr,
) -> impl Future<Output = Result<RowsAffected>> + Send
where Self: Sized;
fn row_filtered(&self) -> Box<[(&'static str, Value)]>;
fn row_full(&self) -> Row;
fn primary_key(&self) -> Self::PrimaryKey<'_>;
// Provided methods
fn find_one<Exec: Executor, Expr: Expression>(
executor: &mut Exec,
condition: &Expr,
) -> impl Future<Output = Result<Option<Self>>> + Send
where Self: Sized { ... }
fn save<Exec: Executor>(
&self,
executor: &mut Exec,
) -> impl Future<Output = Result<()>> + Send
where Self: Sized { ... }
fn delete<Exec: Executor>(
&self,
executor: &mut Exec,
) -> impl Future<Output = Result<()>> + Send
where Self: Sized { ... }
}
Required Associated Types§
type PrimaryKey<'a>
Required Methods§
fn table_ref() -> &'static TableRef
fn columns() -> &'static [ColumnDef]
fn primary_key_def() -> impl ExactSizeIterator<Item = &'static ColumnDef>
fn unique_defs() -> impl ExactSizeIterator<Item = impl ExactSizeIterator<Item = &'static ColumnDef>>
fn from_row(row: RowLabeled) -> Result<Self>where
Self: Sized,
fn create_table<Exec: Executor>( executor: &mut Exec, if_not_exists: bool, create_schema: bool, ) -> impl Future<Output = Result<()>> + Send
fn drop_table<Exec: Executor>( executor: &mut Exec, if_exists: bool, drop_schema: bool, ) -> impl Future<Output = Result<()>> + Send
fn insert_one<Exec: Executor, E: Entity>( executor: &mut Exec, entity: &E, ) -> impl Future<Output = Result<RowsAffected>> + Send
fn insert_many<'a, Exec, It>( executor: &mut Exec, items: It, ) -> impl Future<Output = Result<RowsAffected>> + Send
fn find_pk<Exec: Executor>(
executor: &mut Exec,
primary_key: &Self::PrimaryKey<'_>,
) -> impl Future<Output = Result<Option<Self>>> + Sendwhere
Self: Sized,
fn find_many<Exec: Executor, Expr: Expression>(
executor: &mut Exec,
condition: &Expr,
limit: Option<u32>,
) -> impl Stream<Item = Result<Self>> + Sendwhere
Self: Sized,
fn delete_one<Exec: Executor>(
executor: &mut Exec,
primary_key: Self::PrimaryKey<'_>,
) -> impl Future<Output = Result<RowsAffected>> + Sendwhere
Self: Sized,
fn delete_many<Exec: Executor, Expr: Expression>(
executor: &mut Exec,
condition: &Expr,
) -> impl Future<Output = Result<RowsAffected>> + Sendwhere
Self: Sized,
fn row_filtered(&self) -> Box<[(&'static str, Value)]>
fn row_full(&self) -> Row
fn primary_key(&self) -> Self::PrimaryKey<'_>
Provided Methods§
fn find_one<Exec: Executor, Expr: Expression>(
executor: &mut Exec,
condition: &Expr,
) -> impl Future<Output = Result<Option<Self>>> + Sendwhere
Self: Sized,
fn save<Exec: Executor>(
&self,
executor: &mut Exec,
) -> impl Future<Output = Result<()>> + Sendwhere
Self: Sized,
fn delete<Exec: Executor>(
&self,
executor: &mut Exec,
) -> impl Future<Output = Result<()>> + Sendwhere
Self: Sized,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.