zino_connector

Trait Connector

Source
pub trait Connector {
    // Required methods
    fn try_new_data_source(config: &Table) -> Result<DataSource, Error>;
    async fn execute(
        &self,
        query: &str,
        params: Option<&Map>,
    ) -> Result<Option<u64>, Error>;
    async fn query(
        &self,
        query: &str,
        params: Option<&Map>,
    ) -> Result<Vec<Record>, Error>;
    async fn query_one(
        &self,
        query: &str,
        params: Option<&Map>,
    ) -> Result<Option<Record>, Error>;

    // Provided methods
    async fn query_as<T: DeserializeOwned>(
        &self,
        query: &str,
        params: Option<&Map>,
    ) -> Result<Vec<T>, Error> { ... }
    async fn query_one_as<T: DeserializeOwned>(
        &self,
        query: &str,
        params: Option<&Map>,
    ) -> Result<Option<T>, Error> { ... }
}
Expand description

Underlying trait of all data sources for implementors.

Required Methods§

Source

fn try_new_data_source(config: &Table) -> Result<DataSource, Error>

Constructs a new data source with the configuration, returning an error if it fails.

Source

async fn execute( &self, query: &str, params: Option<&Map>, ) -> Result<Option<u64>, Error>

Executes the query and returns the total number of rows affected.

Source

async fn query( &self, query: &str, params: Option<&Map>, ) -> Result<Vec<Record>, Error>

Executes the query and parses it as Vec<Record>.

Source

async fn query_one( &self, query: &str, params: Option<&Map>, ) -> Result<Option<Record>, Error>

Executes the query and parses it as a Record.

Provided Methods§

Source

async fn query_as<T: DeserializeOwned>( &self, query: &str, params: Option<&Map>, ) -> Result<Vec<T>, Error>

Executes the query and parses it as Vec<T>.

Source

async fn query_one_as<T: DeserializeOwned>( &self, query: &str, params: Option<&Map>, ) -> Result<Option<T>, Error>

Executes the query and parses it as an instance of type T.

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 Connector for MySqlPool

Available on crate feature connector-mysql only.
Source§

fn try_new_data_source(config: &Table) -> Result<DataSource, Error>

Source§

async fn execute( &self, query: &str, params: Option<&Map>, ) -> Result<Option<u64>, Error>

Source§

async fn query( &self, query: &str, params: Option<&Map>, ) -> Result<Vec<Record>, Error>

Source§

async fn query_as<T: DeserializeOwned>( &self, query: &str, params: Option<&Map>, ) -> Result<Vec<T>, Error>

Source§

async fn query_one( &self, query: &str, params: Option<&Map>, ) -> Result<Option<Record>, Error>

Source§

async fn query_one_as<T: DeserializeOwned>( &self, query: &str, params: Option<&Map>, ) -> Result<Option<T>, Error>

Source§

impl Connector for PgPool

Available on crate feature connector-postgres only.
Source§

fn try_new_data_source(config: &Table) -> Result<DataSource, Error>

Source§

async fn execute( &self, query: &str, params: Option<&Map>, ) -> Result<Option<u64>, Error>

Source§

async fn query( &self, query: &str, params: Option<&Map>, ) -> Result<Vec<Record>, Error>

Source§

async fn query_as<T: DeserializeOwned>( &self, query: &str, params: Option<&Map>, ) -> Result<Vec<T>, Error>

Source§

async fn query_one( &self, query: &str, params: Option<&Map>, ) -> Result<Option<Record>, Error>

Source§

async fn query_one_as<T: DeserializeOwned>( &self, query: &str, params: Option<&Map>, ) -> Result<Option<T>, Error>

Source§

impl Connector for SqlitePool

Available on crate feature connector-sqlite only.
Source§

fn try_new_data_source(config: &Table) -> Result<DataSource, Error>

Source§

async fn execute( &self, query: &str, params: Option<&Map>, ) -> Result<Option<u64>, Error>

Source§

async fn query( &self, query: &str, params: Option<&Map>, ) -> Result<Vec<Record>, Error>

Source§

async fn query_as<T: DeserializeOwned>( &self, query: &str, params: Option<&Map>, ) -> Result<Vec<T>, Error>

Source§

async fn query_one( &self, query: &str, params: Option<&Map>, ) -> Result<Option<Record>, Error>

Source§

async fn query_one_as<T: DeserializeOwned>( &self, query: &str, params: Option<&Map>, ) -> Result<Option<T>, Error>

Implementors§

Source§

impl Connector for ArrowConnector

Available on crate feature connector-arrow only.
Source§

impl Connector for DataSource

Source§

impl Connector for HttpConnector

Available on crate feature connector-http only.