Trait iron_rusqlite_middleware::RusqliteRequestExtension [−][src]
pub trait RusqliteRequestExtension { fn database_connection(&self) -> PooledConnection<SqliteConnectionManager>; }
Trait which adds a method the iron::Request
to enable the retrieval of a database connection.
Example
ⓘThis example is not tested
use iron_rusqlite_middleware::RusqliteMiddlewareExtension; fn handler(req: &mut Request) -> IronResult<Response> { let conn = req.database_connection(); // Do stuff with the rusqlite::Connection object Ok(Response::with((status::Ok, "Done."))) }
Required Methods
fn database_connection(&self) -> PooledConnection<SqliteConnectionManager>
Returns a pooled connection to the SQLite database. The connection is automatically returned to the connection pool when the pool connection is dropped.
Panics if the RusqliteMiddleware
has not been added to the Iron app, or if retrieving
the database connection times out.
Implementations on Foreign Types
impl<'a, 'b> RusqliteRequestExtension for Request<'a, 'b>
[src]
impl<'a, 'b> RusqliteRequestExtension for Request<'a, 'b>
Implementation of the RusqliteRequestExention
for the iron::Request
.
fn database_connection(&self) -> SqliteConnection
[src]
fn database_connection(&self) -> SqliteConnection