pub trait Operations {
// Required methods
fn execute<'a, F>(
&self,
statement: String,
callback_fn: Option<F>,
) -> Result<SqlitePrimaryResult, MinSqliteWrapperError<'a>>
where F: FnOnce(SqlitePrimaryResult, String);
fn prepare<'a, F>(
&self,
statement: String,
callback_fn: Option<F>,
) -> Result<SqlStatement, MinSqliteWrapperError<'a>>
where F: FnOnce(SqlitePrimaryResult, String);
}Expand description
Defines SQL functions.
Required Methods§
Sourcefn execute<'a, F>(
&self,
statement: String,
callback_fn: Option<F>,
) -> Result<SqlitePrimaryResult, MinSqliteWrapperError<'a>>
fn execute<'a, F>( &self, statement: String, callback_fn: Option<F>, ) -> Result<SqlitePrimaryResult, MinSqliteWrapperError<'a>>
A wrapper around prepare(), execute_prepared(), and kill(), that allows an application to run multiple statements of SQL without having to use a lot of Rust code.
§Warning
This function does not provide to read data from SQLite.
§Usage
let db_path = Path::new(“./example.db”); let db = Database::open(db_path).unwrap();
let status = db.execute(statement, None::<Box<dyn FnOnce(SqlitePrimaryResult, String)>>).unwrap();
if status != SqlitePrimaryResult::Ok { … }
db.close();
Sourcefn prepare<'a, F>(
&self,
statement: String,
callback_fn: Option<F>,
) -> Result<SqlStatement, MinSqliteWrapperError<'a>>
fn prepare<'a, F>( &self, statement: String, callback_fn: Option<F>, ) -> Result<SqlStatement, MinSqliteWrapperError<'a>>
Prepares SQL operation to be executed and then destroy.
§Warning
kill() must be called for each result of the prepare() function in order to avoid resource leak.
§Usage
let db_path = Path::new(“./example.db”); let db = Database::open(db_path).unwrap();
let statement = String::from( “SELECT * FROM example_table WHERE ID = ‘15’;” );
let mut sql = db.prepare(statement, None::<Box<dyn FnOnce(SqlitePrimaryResult, String)>>).unwrap();
while let PreparedStatementStatus::FoundRow = sql.execute_prepared() { … }
sql.kill(); db.close();
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.