pub enum DatabaseConfiguration {
SqlitePersistent {
path: PathBuf,
single_connection: bool,
},
SqliteInMemory {
single_connection: bool,
},
Postgres {
host: String,
port: u16,
database_name: String,
user: Option<DatabaseUser>,
},
}Expand description
Configuration for the database. We either use Sqlite or Postgres
Variants§
SqlitePersistent
Configuration for a SQLite database
Fields
SqliteInMemory
Configuration for a SQLite database
Postgres
Configuration for a Postgres database
Implementations§
Source§impl DatabaseConfiguration
impl DatabaseConfiguration
Sourcepub fn postgres() -> Result<Option<DatabaseConfiguration>>
pub fn postgres() -> Result<Option<DatabaseConfiguration>>
Create a postgres database configuration from environment variables.
At minima, the database host and port must be provided.
Sourcepub fn sqlite(path: &Path) -> DatabaseConfiguration
pub fn sqlite(path: &Path) -> DatabaseConfiguration
Create a local sqlite configuration
Sourcepub fn sqlite_in_memory() -> DatabaseConfiguration
pub fn sqlite_in_memory() -> DatabaseConfiguration
Create an in-memory sqlite configuration
Sourcepub fn single_connection(&self) -> Self
pub fn single_connection(&self) -> Self
Create a single connection sqlite configuration
Sourcepub fn database_type(&self) -> DatabaseType
pub fn database_type(&self) -> DatabaseType
Return the type of database that has been configured
Sourcepub fn connection_string(&self) -> String
pub fn connection_string(&self) -> String
Return the type of database that has been configured
Sourcepub fn create_directory_if_necessary(&self) -> Result<()>
pub fn create_directory_if_necessary(&self) -> Result<()>
Create a directory for the SQLite database file if necessary
Trait Implementations§
Source§impl Clone for DatabaseConfiguration
impl Clone for DatabaseConfiguration
Source§fn clone(&self) -> DatabaseConfiguration
fn clone(&self) -> DatabaseConfiguration
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DatabaseConfiguration
impl Debug for DatabaseConfiguration
Source§impl PartialEq for DatabaseConfiguration
impl PartialEq for DatabaseConfiguration
impl Eq for DatabaseConfiguration
impl StructuralPartialEq for DatabaseConfiguration
Auto Trait Implementations§
impl Freeze for DatabaseConfiguration
impl RefUnwindSafe for DatabaseConfiguration
impl Send for DatabaseConfiguration
impl Sync for DatabaseConfiguration
impl Unpin for DatabaseConfiguration
impl UnwindSafe for DatabaseConfiguration
Blanket Implementations§
Source§impl<D> AsyncTryClone for D
impl<D> AsyncTryClone for D
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 more