Struct Connection

Source
pub struct Connection { /* private fields */ }
Expand description

A database connection.

Implementations§

Source§

impl Connection

Source

pub fn open<T: AsRef<Path>>(path: T) -> Result<Connection>

Open a read-write connection to a new or existing database.

Source

pub fn open_with_flags<T: AsRef<Path>>( path: T, flags: OpenFlags, ) -> Result<Connection>

Open a database connection with specific flags.

Source

pub fn execute<T: AsRef<str>>(&self, statement: T) -> Result<()>

Execute a statement without processing the resulting rows if any.

Source

pub fn iterate<T: AsRef<str>, F>(&self, statement: T, callback: F) -> Result<()>
where F: FnMut(&[(&str, Option<&str>)]) -> bool,

Execute a statement and process the resulting rows as plain text.

The callback is triggered for each row. If the callback returns false, no more rows will be processed. For large queries and non-string data types, prepared statement are highly preferable; see prepare.

Source

pub fn prepare<T: AsRef<str>>(&self, statement: T) -> Result<Statement>

Create a prepared statement.

Source

pub fn changes(&self) -> usize

Return the number of rows inserted, updated, or deleted by the most recent INSERT, UPDATE, or DELETE statement.

Source

pub fn total_changes(&self) -> usize

Return the total number of rows inserted, updated, and deleted by all INSERT, UPDATE, and DELETE statements since the connection was opened.

Source

pub fn set_busy_timeout(&mut self, milliseconds: usize) -> Result<()>

Set an implicit callback for handling busy events that tries to repeat rejected operations until a timeout expires.

Source

pub fn as_raw(&self) -> u32

Return the raw pointer.

Trait Implementations§

Source§

impl Drop for Connection

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Connection

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.