pub trait MetadataExecutor {
type Row;
// Required methods
fn query_one(
&mut self,
operation: &'static str,
statement: &str,
params: MetadataParameters<'_>,
) -> Result<Self::Row, PgMetaError>;
fn query_optional(
&mut self,
operation: &'static str,
statement: &str,
params: MetadataParameters<'_>,
) -> Result<Option<Self::Row>, PgMetaError>;
fn query_many(
&mut self,
operation: &'static str,
statement: &str,
params: MetadataParameters<'_>,
) -> Result<Vec<Self::Row>, PgMetaError>;
fn execute_command(
&mut self,
operation: &'static str,
statement: &str,
params: MetadataParameters<'_>,
) -> Result<u64, PgMetaError>;
fn with_transaction<T>(
&mut self,
operation: &'static str,
f: impl FnOnce(&mut dyn MetadataTransaction<Row = Self::Row>) -> Result<T, PgMetaError>,
) -> Result<T, PgMetaError>;
}Expand description
Session-scoped metadata execution interface.
Required Associated Types§
Required Methods§
Sourcefn query_one(
&mut self,
operation: &'static str,
statement: &str,
params: MetadataParameters<'_>,
) -> Result<Self::Row, PgMetaError>
fn query_one( &mut self, operation: &'static str, statement: &str, params: MetadataParameters<'_>, ) -> Result<Self::Row, PgMetaError>
Runs a query expected to return exactly one row.
§Errors
Returns an error when PostgreSQL/libpq rejects the query or the result shape does not match the executor contract.
Sourcefn query_optional(
&mut self,
operation: &'static str,
statement: &str,
params: MetadataParameters<'_>,
) -> Result<Option<Self::Row>, PgMetaError>
fn query_optional( &mut self, operation: &'static str, statement: &str, params: MetadataParameters<'_>, ) -> Result<Option<Self::Row>, PgMetaError>
Runs a query expected to return zero or one row.
§Errors
Returns an error when PostgreSQL/libpq rejects the query or the result shape contains more than one row.
Sourcefn query_many(
&mut self,
operation: &'static str,
statement: &str,
params: MetadataParameters<'_>,
) -> Result<Vec<Self::Row>, PgMetaError>
fn query_many( &mut self, operation: &'static str, statement: &str, params: MetadataParameters<'_>, ) -> Result<Vec<Self::Row>, PgMetaError>
Runs a query that can return many rows.
§Errors
Returns an error when PostgreSQL/libpq rejects the query or parameters.
Sourcefn execute_command(
&mut self,
operation: &'static str,
statement: &str,
params: MetadataParameters<'_>,
) -> Result<u64, PgMetaError>
fn execute_command( &mut self, operation: &'static str, statement: &str, params: MetadataParameters<'_>, ) -> Result<u64, PgMetaError>
Executes a metadata write command.
§Errors
Returns an error when PostgreSQL/libpq rejects the command or parameters.
Sourcefn with_transaction<T>(
&mut self,
operation: &'static str,
f: impl FnOnce(&mut dyn MetadataTransaction<Row = Self::Row>) -> Result<T, PgMetaError>,
) -> Result<T, PgMetaError>
fn with_transaction<T>( &mut self, operation: &'static str, f: impl FnOnce(&mut dyn MetadataTransaction<Row = Self::Row>) -> Result<T, PgMetaError>, ) -> Result<T, PgMetaError>
Runs caller-supplied work inside a metadata transaction.
§Errors
Returns an error if the transaction cannot be opened or committed, or if the callback returns an error.
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.