Skip to main content

MetadataExecutor

Trait MetadataExecutor 

Source
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§

Source

type Row

Row representation returned by the concrete executor.

Required Methods§

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl MetadataExecutor for LibpqOAuthConnection

Source§

type Row = LibpqOAuthRow

Source§

fn query_one( &mut self, operation: &'static str, statement: &str, params: MetadataParameters<'_>, ) -> Result<Self::Row, PgMetaError>

Source§

fn query_optional( &mut self, operation: &'static str, statement: &str, params: MetadataParameters<'_>, ) -> Result<Option<Self::Row>, PgMetaError>

Source§

fn query_many( &mut self, operation: &'static str, statement: &str, params: MetadataParameters<'_>, ) -> Result<Vec<Self::Row>, PgMetaError>

Source§

fn execute_command( &mut self, operation: &'static str, statement: &str, params: MetadataParameters<'_>, ) -> Result<u64, PgMetaError>

Source§

fn with_transaction<T>( &mut self, operation: &'static str, f: impl FnOnce(&mut dyn MetadataTransaction<Row = Self::Row>) -> Result<T, PgMetaError>, ) -> Result<T, PgMetaError>

Implementors§