Skip to main content

Hematite

Struct Hematite 

Source
pub struct Hematite {
    pub connection: Connection,
}
Expand description

High-level interface for SQL operations

Fields§

§connection: Connection

Implementations§

Source§

impl Hematite

Source

pub fn new_in_memory() -> Result<Self>

Create a new database instance with an in-memory database

Source

pub fn new(database_path: &str) -> Result<Self>

Create a new database instance with a file-based database

Source

pub fn execute(&mut self, sql: &str) -> Result<StatementResult>

Execute a SQL statement and return the result

Source

pub fn query(&mut self, sql: &str) -> Result<ResultSet>

Execute a SQL query and return the result set

Source

pub fn query_row<F, R>(&mut self, sql: &str, f: F) -> Result<Option<R>>
where F: FnOnce(&Row) -> Result<R>,

Execute a SQL statement and return the first row of the result

Source

pub fn query_one<T>(&mut self, sql: &str) -> Result<Option<T>>
where T: FromValue,

Execute a SQL statement and return the first column of the first row

Source

pub fn query_as<T>(&mut self, sql: &str) -> Result<Vec<T>>
where T: FromRow,

Source

pub fn query_one_as<T>(&mut self, sql: &str) -> Result<Option<T>>
where T: FromRow,

Source

pub fn prepare(&mut self, sql: &str) -> Result<PreparedStatement>

Prepare a SQL statement for repeated execution

Source

pub fn execute_prepared( &mut self, stmt: &mut PreparedStatement, ) -> Result<StatementResult>

Execute a prepared statement

Source

pub fn execute_result(&mut self, sql: &str) -> Result<ExecutedStatement>

Source

pub fn iter_script<'a>(&'a mut self, sql: &str) -> Result<ScriptIter<'a>>

Source

pub fn transaction(&mut self) -> Result<Transaction<'_>>

Begin a new transaction

Source

pub fn journal_mode(&self) -> Result<JournalMode>

Source

pub fn set_journal_mode(&mut self, journal_mode: JournalMode) -> Result<()>

Source

pub fn checkpoint_wal(&mut self) -> Result<()>

Source

pub fn execute_batch(&mut self, sql: &str) -> Result<()>

Execute multiple SQL statements in sequence

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.