pub struct Database { /* private fields */ }Expand description
A thin wrapper around deadpool_postgres used by Tusk.
The Database type manages a connection pool for your application and is
created through Database::new. Connections are retrieved via
Database::get_connection and passed into route handlers through the
Request type.
Implementations§
Source§impl Database
impl Database
Sourcepub async fn new(config: DatabaseConfig) -> Option<Database>
pub async fn new(config: DatabaseConfig) -> Option<Database>
Create a new connection pool from the provided DatabaseConfig.
Returns None if the pool could not be created.
Sourcepub async fn get_connection(&self) -> Result<DatabaseConnection, PoolError>
pub async fn get_connection(&self) -> Result<DatabaseConnection, PoolError>
Retrieve a DatabaseConnection from the pool.
This should be called for every incoming request and the returned connection passed to your route handlers.
Trait Implementations§
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§
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