2626//! support can be easily extended by implementing the [`Poolable`] trait. See 
2727//! [Extending](#extending) for more. 
2828//! 
29- //! [`r2d2`]: https://crates.io/crates/r2d2 
30- //! [request guards]: [rocket::FromRequest] 
31- //! 
3229//! ## Example 
3330//! 
3431//! Before using this library, the feature corresponding to your database type 
204201//! generates an implementation of the [`Deref`](::std::ops::Deref) trait with 
205202//! the internal `Poolable` type as the target. 
206203//! 
207- //! [`FromRequest`]: /rocket/request/trait.FromRequest.html 
208- //! 
209204//! The macro will also generate two inherent methods on the decorated type: 
210205//! 
211206//!   * `fn fairing() -> impl Fairing` 
316311//! The list below includes all presently supported database adapters and their 
317312//! corresponding [`Poolable`] type. 
318313//! 
319- //! | Kind     | Driver                | [ `Poolable`]  Type              | Feature                | 
314+ //! | Kind     | Driver                | `Poolable` Type                 | Feature                | 
320315//! |----------|-----------------------|--------------------------------|------------------------| 
321316//! | MySQL    | [Diesel]              | [`diesel::MysqlConnection`]    | `diesel_mysql_pool`    | 
322- //! | MySQL    | [`rust-mysql-simple`] | [`mysql::conn `]                | `mysql_pool`           | 
317+ //! | MySQL    | [`rust-mysql-simple`] | [`mysql::Conn `]                | `mysql_pool`           | 
323318//! | Postgres | [Diesel]              | [`diesel::PgConnection`]       | `diesel_postgres_pool` | 
324319//! | Postgres | [Rust-Postgres]       | [`postgres::Connection`]       | `postgres_pool`        | 
325320//! | Sqlite   | [Diesel]              | [`diesel::SqliteConnection`]   | `diesel_sqlite_pool`   | 
326- //! | Sqlite   | [` Rustqlite`]          | [`rusqlite::Connection`]       | `sqlite_pool`          | 
321+ //! | Sqlite   | [Rustqlite]            | [`rusqlite::Connection`]       | `sqlite_pool`          | 
327322//! | Neo4j    | [`rusted_cypher`]     | [`rusted_cypher::GraphClient`] | `cypher_pool`          | 
328323//! | Redis    | [`redis-rs`]          | [`redis::Connection`]          | `redis_pool`           | 
329324//! 
338333//! [`diesel::MysqlConnection`]: http://docs.diesel.rs/diesel/mysql/struct.MysqlConnection.html 
339334//! [`redis-rs`]: https://github.com/mitsuhiko/redis-rs 
340335//! [`rusted_cypher`]: https://github.com/livioribeiro/rusted-cypher 
341- //! [` Rustqlite` ]: https://github.com/jgallagher/rusqlite 
336+ //! [Rustqlite]: https://github.com/jgallagher/rusqlite 
342337//! [Rust-Postgres]: https://github.com/sfackler/rust-postgres 
343338//! [`rust-mysql-simple`]: https://github.com/blackbeam/rust-mysql-simple 
344339//! [`diesel::PgConnection`]: http://docs.diesel.rs/diesel/pg/struct.PgConnection.html 
355350//! database-like struct that can be pooled by `r2d2`) is as easy as 
356351//! implementing the [`Poolable`] trait. See the documentation for [`Poolable`] 
357352//! for more details on how to implement it. 
353+ //! 
354+ //! [`FromRequest`]: rocket::FromRequest 
355+ //! [request guards]: rocket::FromRequest 
356+ //! [`Poolable`]: databases::Poolable 
358357
359358pub  extern  crate  r2d2; 
360359
@@ -455,7 +454,7 @@ pub enum DatabaseConfigError {
455454/// configuration. 
456455MissingKey , 
457456    /// The configuration associated with the key isn't a 
458- /// [Table](/ rocket/ config/type. Table.html ). 
457+ /// [Table](:: rocket:: config:: Table). 
459458MalformedConfiguration , 
460459    /// The required `url` key is missing. 
461460MissingUrl , 
@@ -612,20 +611,16 @@ impl<'a> Display for DatabaseConfigError {
612611///     `foo::ConnectionManager` 
613612///   * `foo::Error`, errors resulting from manager instantiation 
614613/// 
615- /// [`r2d2`]: https://crates.io/crates/r2d2 
616- /// [`r2d2::ManageConnection`]: http://docs.rs/r2d2/0.8/r2d2/trait.ManageConnection.html 
617- /// 
618614/// In order for Rocket to generate the required code to automatically provision 
619615/// a r2d2 connection pool into application state, the `Poolable` trait needs to 
620616/// be implemented for the connection type. The following example implements 
621617/// `Poolable` for `foo::Connection`: 
622618/// 
623619/// ```rust 
624620/// use rocket_contrib::databases::{r2d2, DbError, DatabaseConfig, Poolable}; 
625- /// 
626621/// # mod foo { 
627- /// #     use rocket_contrib::databases::r2d2; 
628622/// #     use std::fmt; 
623+ /// #     use rocket_contrib::databases::r2d2; 
629624/// #     #[derive(Debug)] pub struct Error; 
630625/// #     impl ::std::error::Error for Error {  } 
631626/// #     impl fmt::Display for Error { 
@@ -637,6 +632,10 @@ impl<'a> Display for DatabaseConfigError {
637632/// # 
638633/// #     type Result<T> = ::std::result::Result<T, Error>; 
639634/// # 
635+ /// #     impl ConnectionManager { 
636+ /// #         pub fn new(url: &str) -> Result<Self> { Err(Error) } 
637+ /// #     } 
638+ /// # 
640639/// #     impl self::r2d2::ManageConnection for ConnectionManager { 
641640/// #          type Connection = Connection; 
642641/// #          type Error = Error; 
@@ -651,16 +650,13 @@ impl<'a> Display for DatabaseConfigError {
651650///     type Error = DbError<foo::Error>; 
652651/// 
653652///     fn pool(config: DatabaseConfig) -> Result<r2d2::Pool<Self::Manager>, Self::Error> { 
654- ///         # let _ = config; /* 
655653///         let manager = foo::ConnectionManager::new(config.url) 
656654///             .map_err(DbError::Custom)?; 
657655/// 
658656///         r2d2::Pool::builder() 
659657///             .max_size(config.pool_size) 
660658///             .build(manager) 
661659///             .map_err(DbError::PoolError) 
662- ///         # */ 
663- ///         # Err(DbError::Custom(foo::Error)) 
664660///     } 
665661/// } 
666662/// ``` 
0 commit comments