pub struct ConnectionBuilder { /* private fields */ }Implementations§
Source§impl ConnectionBuilder
impl ConnectionBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Configure and build a new Connection.
Sourcepub fn thread_builder(self, thread: Builder) -> Self
pub fn thread_builder(self, thread: Builder) -> Self
Configure the thread that the database connection will live on.
Sourcepub fn channel_size(self, size: usize) -> Self
pub fn channel_size(self, size: usize) -> Self
Configure how many functions can be queued to run on our connection
before conn.call(..).await will wait and backpressure will kick in.
Sourcepub fn on_close<F: FnOnce(Option<Connection>) + Send + 'static>(
self,
f: F,
) -> Self
pub fn on_close<F: FnOnce(Option<Connection>) + Send + 'static>( self, f: F, ) -> Self
Configure a function to be called exactly once when the connection is closed.
If the database has already been closed then it will be given None, else it
will be handed the database connection.
Sourcepub async fn open<P: AsRef<Path>>(self, path: P) -> Result<Connection, Error>
pub async fn open<P: AsRef<Path>>(self, path: P) -> Result<Connection, Error>
Open a new connection to an SQLite database. If a database does not exist at the path, one is created.
§Failure
Will return Err if path cannot be converted to a C-compatible string
or if the underlying SQLite open call fails.
Sourcepub async fn open_in_memory(self) -> Result<Connection, Error>
pub async fn open_in_memory(self) -> Result<Connection, Error>
Open a new connection to an in-memory SQLite database.
§Failure
Will return Err if the underlying SQLite open call fails.
Sourcepub async fn open_with_flags<P: AsRef<Path>>(
self,
path: P,
flags: OpenFlags,
) -> Result<Connection, Error>
pub async fn open_with_flags<P: AsRef<Path>>( self, path: P, flags: OpenFlags, ) -> Result<Connection, Error>
Open a new connection to a SQLite database.
Database Connection for a description of valid flag combinations.
§Failure
Will return Err if path cannot be converted to a C-compatible
string or if the underlying SQLite open call fails.
Sourcepub async fn open_with_flags_and_vfs<P: AsRef<Path>, V: IntoName>(
self,
path: P,
flags: OpenFlags,
vfs: impl Into<V>,
) -> Result<Connection, Error>
pub async fn open_with_flags_and_vfs<P: AsRef<Path>, V: IntoName>( self, path: P, flags: OpenFlags, vfs: impl Into<V>, ) -> Result<Connection, Error>
Open a new connection to a SQLite database using the specific flags and vfs name.
Database Connection for a description of valid flag combinations.
§Failure
Will return Err if either path or vfs cannot be converted to a
C-compatible string or if the underlying SQLite open call fails.
Sourcepub async fn open_in_memory_with_flags(
self,
flags: OpenFlags,
) -> Result<Connection, Error>
pub async fn open_in_memory_with_flags( self, flags: OpenFlags, ) -> Result<Connection, Error>
Open a new connection to an in-memory SQLite database.
Database Connection for a description of valid flag combinations.
§Failure
Will return Err if the underlying SQLite open call fails.
Sourcepub async fn open_in_memory_with_flags_and_vfs<V: IntoName>(
self,
flags: OpenFlags,
vfs: impl Into<V>,
) -> Result<Connection, Error>
pub async fn open_in_memory_with_flags_and_vfs<V: IntoName>( self, flags: OpenFlags, vfs: impl Into<V>, ) -> Result<Connection, Error>
Open a new connection to an in-memory SQLite database using the specific flags and vfs name.
Database Connection for a description of valid flag combinations.
§Failure
Will return Err if vfs cannot be converted to a C-compatible
string or if the underlying SQLite open call fails.