pub trait Read:
Table
+ Bind
+ Hooks
+ Send
+ Sync
+ Unpin
+ 'static {
// Required methods
fn read<'e, 'life0, 'async_trait, E>(
executor: E,
pk: &'life0 Self::PrimaryKey,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
where 'e: 'async_trait,
'life0: 'async_trait,
E: Executor<'e, Database = Postgres> + 'async_trait,
<Postgres as Database>::Arguments<'q>: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
Self: 'async_trait;
fn find<'e, 'life0, 'async_trait, E>(
executor: E,
pk: &'life0 Self::PrimaryKey,
) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Error>> + Send + 'async_trait>>
where 'e: 'async_trait,
'life0: 'async_trait,
E: Executor<'e, Database = Postgres> + 'async_trait,
<Postgres as Database>::Arguments<'q>: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
Self: 'async_trait;
fn read_all<'e, 'async_trait, E>(
executor: E,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self>, Error>> + Send + 'async_trait>>
where 'e: 'async_trait,
E: Executor<'e, Database = Postgres> + 'async_trait,
<Postgres as Database>::Arguments<'q>: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
Self: 'async_trait;
fn reload<'e, 'life0, 'async_trait, E>(
&'life0 mut self,
executor: E,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'e: 'async_trait,
'life0: 'async_trait,
E: Executor<'e, Database = Postgres> + 'async_trait,
<Postgres as Database>::Arguments<'q>: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
Self: 'async_trait;
}Expand description
Trait for reading rows from a database.
This trait provides the functionality for reading data from tables in a SQL database. It defines several asynchronous methods for retrieving rows either by their primary key, reloading existing entities, or fetching all rows in a table. The trait incorporates hooks at various stages, allowing for custom logic to be executed as part of the reading process.
Required Methods§
Sourcefn read<'e, 'life0, 'async_trait, E>(
executor: E,
pk: &'life0 Self::PrimaryKey,
) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
fn read<'e, 'life0, 'async_trait, E>( executor: E, pk: &'life0 Self::PrimaryKey, ) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
Finds and retrieves a row by its primary key. This method constructs a query to fetch a single row based on the primary key, executes it, and returns the result, optionally triggering hooks before and after execution.
Sourcefn find<'e, 'life0, 'async_trait, E>(
executor: E,
pk: &'life0 Self::PrimaryKey,
) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Error>> + Send + 'async_trait>>
fn find<'e, 'life0, 'async_trait, E>( executor: E, pk: &'life0 Self::PrimaryKey, ) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Error>> + Send + 'async_trait>>
Finds and retrieves a row by its primary key. This method constructs a query to fetch a single row based on the primary key, executes it, and returns the result, optionally triggering hooks before and after execution.
Sourcefn read_all<'e, 'async_trait, E>(
executor: E,
) -> Pin<Box<dyn Future<Output = Result<Vec<Self>, Error>> + Send + 'async_trait>>
fn read_all<'e, 'async_trait, E>( executor: E, ) -> Pin<Box<dyn Future<Output = Result<Vec<Self>, Error>> + Send + 'async_trait>>
Retrieves all rows from the table. This method is useful for fetching the complete dataset of a table, executing a query to return all rows, and applying hooks as needed.
Sourcefn reload<'e, 'life0, 'async_trait, E>(
&'life0 mut self,
executor: E,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
fn reload<'e, 'life0, 'async_trait, E>( &'life0 mut self, executor: E, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
Reloads the current entity from the database. This method is designed to update the entity instance with the latest data from the database, ensuring that it reflects the current state of the corresponding row.
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.