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§
type Connection
type Error: Error
type ConnectionError: Error
Sourcetype ConnectionRef<'c>
type ConnectionRef<'c>
Represents the reference to a connection type. Some drivers my specify this as immutable or mutable reference.
Required Methods§
Sourcefn new_read_connection(
path: &Path,
) -> Result<Self::Connection, Self::ConnectionError>
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.
Sourcefn new_write_connection(
path: &Path,
) -> Result<Self::Connection, Self::ConnectionError>
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.
Sourcefn begin_transaction(
connection: &mut Self::Connection,
sql: &str,
) -> Result<(), Self::Error>
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.
Sourcefn commit_transaction(
connection: &mut Self::Connection,
) -> Result<(), Self::Error>
fn commit_transaction( connection: &mut Self::Connection, ) -> Result<(), Self::Error>
Sourcefn rollback_transaction(
connection: &mut Self::Connection,
) -> Result<(), Self::Error>
fn rollback_transaction( connection: &mut Self::Connection, ) -> Result<(), Self::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.