pub trait Persistence: AsyncPersistence {
// Provided methods
fn save_sync(&mut self) -> Result<(), RecordError>
where Self: Serialize,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send { ... }
fn save_bang_sync(&mut self) -> Result<(), RecordError>
where Self: Serialize,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send { ... }
fn create_sync(attrs: HashMap<String, Value>) -> Result<Self, RecordError>
where Self: Default + Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send { ... }
fn insert_all_sync(
records: Vec<HashMap<String, Value>>,
) -> Result<Vec<Self>, RecordError>
where Self: Default + Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send { ... }
fn upsert_sync(
attrs: HashMap<String, Value>,
unique_by: &[&str],
) -> Result<Self, RecordError>
where Self: Default + Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send { ... }
fn upsert_all_sync(
records: Vec<HashMap<String, Value>>,
unique_by: &[&str],
) -> Result<Vec<Self>, RecordError>
where Self: Default + Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send { ... }
fn update_attributes_sync(
&mut self,
attrs: HashMap<String, Value>,
) -> Result<(), RecordError>
where Self: Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send { ... }
fn destroy_sync(&mut self) -> Result<(), RecordError>
where <Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable { ... }
fn reload_sync(&mut self) -> Result<(), RecordError>
where <Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable { ... }
fn delete_sync(id: i64) -> Result<(), RecordError>
where <Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable { ... }
fn update_all_sync(
conditions: HashMap<String, Value>,
updates: HashMap<String, Value>,
) -> Result<u64, RecordError>
where <Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable { ... }
fn destroy_all_sync(
conditions: HashMap<String, Value>,
) -> Result<u64, RecordError>
where <Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable { ... }
}Expand description
Synchronous persistence interface for [Record] types.
Provided Methods§
Sourcefn save_sync(&mut self) -> Result<(), RecordError>where
Self: Serialize,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
fn save_sync(&mut self) -> Result<(), RecordError>where
Self: Serialize,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
Saves the record, inserting or updating based on its current state.
Sourcefn save_bang_sync(&mut self) -> Result<(), RecordError>where
Self: Serialize,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
fn save_bang_sync(&mut self) -> Result<(), RecordError>where
Self: Serialize,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
Saves the record and preserves validation-style error reporting.
Sourcefn create_sync(attrs: HashMap<String, Value>) -> Result<Self, RecordError>where
Self: Default + Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
fn create_sync(attrs: HashMap<String, Value>) -> Result<Self, RecordError>where
Self: Default + Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
Creates a new record from a string-keyed attribute map.
Sourcefn insert_all_sync(
records: Vec<HashMap<String, Value>>,
) -> Result<Vec<Self>, RecordError>where
Self: Default + Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
fn insert_all_sync(
records: Vec<HashMap<String, Value>>,
) -> Result<Vec<Self>, RecordError>where
Self: Default + Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
Inserts multiple records at once.
Sourcefn upsert_sync(
attrs: HashMap<String, Value>,
unique_by: &[&str],
) -> Result<Self, RecordError>where
Self: Default + Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
fn upsert_sync(
attrs: HashMap<String, Value>,
unique_by: &[&str],
) -> Result<Self, RecordError>where
Self: Default + Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
Inserts a record, or updates it if a matching row already exists.
Sourcefn upsert_all_sync(
records: Vec<HashMap<String, Value>>,
unique_by: &[&str],
) -> Result<Vec<Self>, RecordError>where
Self: Default + Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
fn upsert_all_sync(
records: Vec<HashMap<String, Value>>,
unique_by: &[&str],
) -> Result<Vec<Self>, RecordError>where
Self: Default + Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
Inserts or updates multiple records at once.
Sourcefn update_attributes_sync(
&mut self,
attrs: HashMap<String, Value>,
) -> Result<(), RecordError>where
Self: Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
fn update_attributes_sync(
&mut self,
attrs: HashMap<String, Value>,
) -> Result<(), RecordError>where
Self: Serialize + DeserializeOwned,
<Self::Entity as EntityTrait>::Column: ColumnTrait + Iterable,
<Self::Entity as EntityTrait>::Model: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel>,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior + Send,
Updates the record with the provided attributes and saves the result.
Sourcefn destroy_sync(&mut self) -> Result<(), RecordError>
fn destroy_sync(&mut self) -> Result<(), RecordError>
Deletes the record from the database and marks it destroyed.
Sourcefn reload_sync(&mut self) -> Result<(), RecordError>
fn reload_sync(&mut self) -> Result<(), RecordError>
Reloads the record from the database.
Sourcefn delete_sync(id: i64) -> Result<(), RecordError>
fn delete_sync(id: i64) -> Result<(), RecordError>
Deletes a row by primary key without instantiating a wrapper value.
Sourcefn update_all_sync(
conditions: HashMap<String, Value>,
updates: HashMap<String, Value>,
) -> Result<u64, RecordError>
fn update_all_sync( conditions: HashMap<String, Value>, updates: HashMap<String, Value>, ) -> Result<u64, RecordError>
Updates all rows matching the provided conditions and returns the affected row count.
Sourcefn destroy_all_sync(
conditions: HashMap<String, Value>,
) -> Result<u64, RecordError>
fn destroy_all_sync( conditions: HashMap<String, Value>, ) -> Result<u64, RecordError>
Deletes all rows matching the provided conditions and returns the affected row count.
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.