pub struct DatabaseManager { /* private fields */ }Expand description
Manages SQLite database connections
Supports multiple simultaneous database connections, each identified by a unique name derived from the file path.
§Test Isolation
- Create new
DatabaseManagerinstances for isolated tests - The global
DATABASE_MANAGERis shared; useclose_all()for cleanup
Implementations§
Source§impl DatabaseManager
impl DatabaseManager
Sourcepub fn open(&self, path: &Path, create: bool) -> Result<String, SqliteToolError>
pub fn open(&self, path: &Path, create: bool) -> Result<String, SqliteToolError>
Opens or creates a database connection
If create is false and the database doesn’t exist, returns an error.
If the database is already open, returns the existing connection.
Returns the database identifier (normalized path) for future reference.
Sourcepub fn get(
&self,
name: Option<&str>,
) -> Result<Arc<Mutex<Connection>>, SqliteToolError>
pub fn get( &self, name: Option<&str>, ) -> Result<Arc<Mutex<Connection>>, SqliteToolError>
Gets a connection by name, or the default connection if name is None
Sourcepub fn set_default(&self, name: &str) -> Result<(), SqliteToolError>
pub fn set_default(&self, name: &str) -> Result<(), SqliteToolError>
Sets the default database (thread-local)
Sourcepub fn get_default(&self) -> Option<String>
pub fn get_default(&self) -> Option<String>
Returns the current default database name
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DatabaseManager
impl RefUnwindSafe for DatabaseManager
impl Send for DatabaseManager
impl Sync for DatabaseManager
impl Unpin for DatabaseManager
impl UnwindSafe for DatabaseManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.