pub trait ModelExtensions: Model + CrudOperations {
// Provided methods
async fn refresh(&mut self, pool: &Pool<Postgres>) -> ModelResult<()>
where Self: Sized { ... }
async fn exists(&self, pool: &Pool<Postgres>) -> ModelResult<bool>
where Self: Sized { ... }
async fn save(&mut self, pool: &Pool<Postgres>) -> ModelResult<()>
where Self: Sized + Clone { ... }
fn duplicate(&self) -> Self
where Self: Sized + Clone { ... }
fn supports_transactions() -> bool
where Self: Sized { ... }
fn is_dirty(&self) -> bool { ... }
fn mark_clean(&mut self) { ... }
fn dirty_fields(&self) -> Vec<&str> { ... }
}Expand description
Extension trait for models with additional utility methods
Provided Methods§
Sourceasync fn refresh(&mut self, pool: &Pool<Postgres>) -> ModelResult<()>where
Self: Sized,
async fn refresh(&mut self, pool: &Pool<Postgres>) -> ModelResult<()>where
Self: Sized,
Refresh this model instance from the database
Sourceasync fn exists(&self, pool: &Pool<Postgres>) -> ModelResult<bool>where
Self: Sized,
async fn exists(&self, pool: &Pool<Postgres>) -> ModelResult<bool>where
Self: Sized,
Check if this model instance exists in the database
async fn save(&mut self, pool: &Pool<Postgres>) -> ModelResult<()>
Sourcefn duplicate(&self) -> Self
fn duplicate(&self) -> Self
Create a clone of this model without the primary key (for duplication)
Sourcefn supports_transactions() -> boolwhere
Self: Sized,
fn supports_transactions() -> boolwhere
Self: Sized,
Placeholder for transaction-scoped model operations Will be fully implemented when derive macros are available
Sourcefn is_dirty(&self) -> bool
fn is_dirty(&self) -> bool
Check if this model has been modified since last save/load Default implementation always returns true - override for dirty tracking
Sourcefn mark_clean(&mut self)
fn mark_clean(&mut self)
Mark all fields as clean (not dirty) after save operations Default implementation is a no-op - override for dirty tracking
Sourcefn dirty_fields(&self) -> Vec<&str>
fn dirty_fields(&self) -> Vec<&str>
Get list of modified fields since last save/load Default implementation returns empty - override for dirty tracking
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".