pub struct Database {
pub pool: ConnectionPool,
}Expand description
Represents a MySQL database connection manager.
The Database struct maintains a connection pool to MySQL and provides
methods for establishing connections with configurable parameters. It uses
SQLx’s connection pooling to efficiently manage database connections.
Fields§
§pool: ConnectionPoolThe connection pool for MySQL connections.
Implementations§
source§impl Database
impl Database
sourcepub async fn connect(
connection_string: &str,
connection_pool_size: u32,
) -> Result<Self>
pub async fn connect( connection_string: &str, connection_pool_size: u32, ) -> Result<Self>
Establishes a new connection pool to MySQL with the specified configuration.
This method initializes a new connection pool with the given parameters and verifies that the connection can be established successfully.
§Arguments
connection_string- The MySQL connection URL (e.g., “mysql://user:password@localhost:3306/database”)connection_pool_size- Maximum number of connections in the pool
§Returns
Returns a Result containing the Database instance if successful, or an
error if the connection could not be established.
§Examples
use darkwing::database::Database;
async fn example() -> anyhow::Result<()> {
let db = Database::connect(
"mysql://user:password@localhost:3306/database",
5
).await?;
Ok(())
}Trait Implementations§
source§impl BrowserProfileAccessRepository for Database
impl BrowserProfileAccessRepository for Database
Implementation of BrowserProfileAccessRepository for the main database.
source§fn get_by_user_id_and_browser_profile_id<'life0, 'async_trait>(
&'life0 self,
user_id: i64,
browser_profile_id: i64,
) -> Pin<Box<dyn Future<Output = Result<Option<BrowserProfileAccess>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_by_user_id_and_browser_profile_id<'life0, 'async_trait>(
&'life0 self,
user_id: i64,
browser_profile_id: i64,
) -> Pin<Box<dyn Future<Output = Result<Option<BrowserProfileAccess>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn get_teamlead_id_by_browser_profile<'life0, 'async_trait>(
&'life0 self,
browser_profile: MiniBrowserProfile,
) -> Pin<Box<dyn Future<Output = Result<Option<i64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_teamlead_id_by_browser_profile<'life0, 'async_trait>(
&'life0 self,
browser_profile: MiniBrowserProfile,
) -> Pin<Box<dyn Future<Output = Result<Option<i64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§impl BrowserProfileRepository for Database
impl BrowserProfileRepository for Database
source§fn get_mini_by_id<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<MiniBrowserProfile>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_mini_by_id<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<MiniBrowserProfile>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn get_preliminary_by_id<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<BrowserProfilePreliminary>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_preliminary_by_id<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<BrowserProfilePreliminary>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn get_by_id_with_fingerprint<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<BrowserProfileWithFingerprint>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_by_id_with_fingerprint<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<BrowserProfileWithFingerprint>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn get_homepages_by_browser_profile_id<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<Vec<Homepage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_homepages_by_browser_profile_id<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<Vec<Homepage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn get_bookmarks<'life0, 'async_trait>(
&'life0 self,
user_id: i64,
team_id: i64,
main_website: MainWebsite,
) -> Pin<Box<dyn Future<Output = Result<Vec<Bookmark>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_bookmarks<'life0, 'async_trait>(
&'life0 self,
user_id: i64,
team_id: i64,
main_website: MainWebsite,
) -> Pin<Box<dyn Future<Output = Result<Vec<Bookmark>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn get_extensions<'life0, 'async_trait>(
&'life0 self,
user_id: i64,
team_id: i64,
) -> Pin<Box<dyn Future<Output = Result<Vec<Extension>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_extensions<'life0, 'async_trait>(
&'life0 self,
user_id: i64,
team_id: i64,
) -> Pin<Box<dyn Future<Output = Result<Vec<Extension>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§impl ProxyRepository for Database
impl ProxyRepository for Database
source§impl SettingsRepository for Database
impl SettingsRepository for Database
Implementation of SettingsRepository for the main Database type.
source§impl TeamsRepository for Database
impl TeamsRepository for Database
Implementation of TeamsRepository for the main Database type.
source§impl UsersRepository for Database
impl UsersRepository for Database
Implementation of UsersRepository for the main database.
This implementation provides the actual database operations using SQLx to interact with the underlying database.
Auto Trait Implementations§
impl Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
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)
clone_to_uninit)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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