Trait Driver

Source
pub trait Driver:
    'static
    + Send
    + Sync
    + Debug {
    type Connection;
    type Error: Error;
    type ConnectionError: Error;
    type ConnectionRef<'c>;

    // Required methods
    fn new_read_connection(
        path: &Path,
    ) -> Result<Self::Connection, Self::ConnectionError>;
    fn new_write_connection(
        path: &Path,
    ) -> Result<Self::Connection, Self::ConnectionError>;
    fn begin_transaction(
        connection: &mut Self::Connection,
        sql: &str,
    ) -> Result<(), Self::Error>;
    fn commit_transaction(
        connection: &mut Self::Connection,
    ) -> Result<(), Self::Error>;
    fn rollback_transaction(
        connection: &mut Self::Connection,
    ) -> Result<(), Self::Error>;
}
Expand description

Implementation interface for any library which provides binding for sqlite.

Required Associated Types§

Source

type Connection

Source

type Error: Error

Source

type ConnectionError: Error

Source

type ConnectionRef<'c>

Represents the reference to a connection type. Some drivers my specify this as immutable or mutable reference.

Required Methods§

Source

fn new_read_connection( path: &Path, ) -> Result<Self::Connection, Self::ConnectionError>

Create new read-only connection with the given path.

This method should not creat the db file if it does not exist.

§Errors

Should return error if the connection could not be created.

Source

fn new_write_connection( path: &Path, ) -> Result<Self::Connection, Self::ConnectionError>

Create a new writable connection with the given path.

This method should create the database file if it does not exist.

§Errors

Should return error if the connection could not be created.

Source

fn begin_transaction( connection: &mut Self::Connection, sql: &str, ) -> Result<(), Self::Error>

Start a transaction with the given sql command.

§Errors

Return error if the transaction could not be started.

Source

fn commit_transaction( connection: &mut Self::Connection, ) -> Result<(), Self::Error>

Commit the transaction.

§Errors

Return error if the transaction could not be commited.

Source

fn rollback_transaction( connection: &mut Self::Connection, ) -> Result<(), Self::Error>

Rollback the transaction.

§Errors

Return error if the transaction could not be rolled back.

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.

Implementors§