pub trait Model:
Sized
+ for<'r> FromRow<'r, AnyRow>
+ Send
+ Unpin
+ 'static {
type New: Send;
const TABLE: &'static str;
const SOFT_DELETE_COLUMN: Option<&'static str> = None;
// Required method
fn create(
data: Self::New,
) -> impl Future<Output = Result<Self, AppError>> + Send;
}Expand description
Implemented automatically by #[derive(Model)].
-> impl Future<...> + Send rather than a plain async fn, matching
larust_repository::Repository’s own established reasoning: trait
async fn doesn’t propagate Send by default, and this needs to be
callable from axum handlers (and from generic code reached by them)
that require Send futures. The generated impl can still be written
as an ordinary async fn - its desugared return type already
satisfies -> impl Future<...>.
Required Associated Constants§
Provided Associated Constants§
Sourceconst SOFT_DELETE_COLUMN: Option<&'static str> = None
const SOFT_DELETE_COLUMN: Option<&'static str> = None
Some(column) only for a struct marked #[soft_deletes] - the
nullable timestamp column delete() sets instead of actually
removing a row. Defaults to None so every other model needs no
changes at all; only the soft-delete-aware code paths
(QueryBuilder’s own filtering, belongs_to_many’s generated
JOIN) ever read this, always at runtime through the real,
monomorphized const for whatever concrete type is in play - never
something a macro invocation elsewhere could see at expansion
time, since it has no visibility into a different struct’s own
#[derive(Model)] attributes.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".