darayus / iron-diesel-middleware Goto Github PK
View Code? Open in Web Editor NEWMiddleware that provides diesel connections for the Iron web framework
License: MIT License
Middleware that provides diesel connections for the Iron web framework
License: MIT License
Could you provide some example usage?
Hi, I just had a question about why you're wrapping the connection pool with Arc
.
The example in the r2d2 readme seems to imply that all you need to do is clone the pool to pass it across a thread boundary. On further inspection, it seems that r2d2's Pool
type uses an Arc
anyway (see here). Is it not redundant to wrap it again?
I'm new to Rust, so forgive me if I'm missing something obvious.
I'm learning Rust, so I'm pretty sure this is a dependency / version mismatch, but I have no clue how to diagnose.
Cargo.toml
[dependencies]
time = "0.1.38"
iron = "0.5"
router = "0.5"
mount = "0.3"
params = "0.6"
iron-sessionstorage = "0.6"
staticfile = "0.4"
diesel = { version = ">= 0.16", features = ["postgres"] }
[dependencies.iron_diesel_middleware]
git = "https://github.com/darayus/iron-diesel-middleware"
Errors
error[E0277]: the trait bound `r2d2_diesel::ConnectionManager<T>: r2d2::ManageConnection` is not satisfied
--> /home/me/.cargo/git/checkouts/iron-diesel-middleware-aafb02dd5d566e9a/75940b7/src/lib.rs:20:3
|
20 | pub pool: DieselPool<T>,
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `r2d2::ManageConnection` is not implemented for `r2d2_diesel::ConnectionManager<T>`
|
= note: required by `r2d2::Pool`
error[E0277]: the trait bound `r2d2_diesel::ConnectionManager<T>: r2d2::ManageConnection` is not satisfied
--> /home/me/.cargo/git/checkouts/iron-diesel-middleware-aafb02dd5d566e9a/75940b7/src/lib.rs:23:51
|
23 | pub struct Value<T: 'static + diesel::Connection>(DieselPool<T>);
| ^^^^^^^^^^^^^^ the trait `r2d2::ManageConnection` is not implemented for `r2d2_diesel::ConnectionManager<T>`
|
= note: required by `r2d2::Pool`
error[E0277]: the trait bound `r2d2_diesel::ConnectionManager<T>: r2d2::ManageConnection` is not satisfied in `r2d2::SharedPool<r2d2_diesel::ConnectionManager<T>>`
--> /home/me/.cargo/git/checkouts/iron-diesel-middleware-aafb02dd5d566e9a/75940b7/src/lib.rs:53:29
|
53 | impl<T: diesel::Connection> BeforeMiddleware for DieselMiddleware<T> {
| ^^^^^^^^^^^^^^^^ within `r2d2::SharedPool<r2d2_diesel::ConnectionManager<T>>`, the trait `r2d2::ManageConnection` is not implemented for `r2d2_diesel::ConnectionManager<T>`
|
= note: required because it appears within the type `r2d2::SharedPool<r2d2_diesel::ConnectionManager<T>>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Arc<r2d2::SharedPool<r2d2_diesel::ConnectionManager<T>>>`
= note: required because it appears within the type `r2d2::Pool<r2d2_diesel::ConnectionManager<T>>`
= note: required because of the requirements on the impl of `std::marker::Sync` for `std::sync::Arc<r2d2::Pool<r2d2_diesel::ConnectionManager<T>>>`
= note: required because it appears within the type `DieselMiddleware<T>`
error[E0277]: the trait bound `r2d2_diesel::ConnectionManager<T>: r2d2::ManageConnection` is not satisfied
--> /home/me/.cargo/git/checkouts/iron-diesel-middleware-aafb02dd5d566e9a/75940b7/src/lib.rs:82:3
|
82 | fn db_conn(&self) -> r2d2::PooledConnection<r2d2_diesel::ConnectionManager<T>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `r2d2::ManageConnection` is not implemented for `r2d2_diesel::ConnectionManager<T>`
|
= note: required by `r2d2::PooledConnection`
error[E0277]: the trait bound `r2d2_diesel::ConnectionManager<T>: r2d2::ManageConnection` is not satisfied
--> /home/me/.cargo/git/checkouts/iron-diesel-middleware-aafb02dd5d566e9a/75940b7/src/lib.rs:86:3
|
86 | / fn db_conn(&self) -> r2d2::PooledConnection<r2d2_diesel::ConnectionManager<T>> {
87 | | let poll_value = self.extensions.get::<DieselMiddleware<T>>().unwrap();
88 | | let &Value(ref poll) = poll_value;
89 | |
90 | | return poll.get().unwrap();
91 | | }
| |___^ the trait `r2d2::ManageConnection` is not implemented for `r2d2_diesel::ConnectionManager<T>`
|
= note: required by `r2d2::PooledConnection`
error: aborting due to 5 previous errors
error: Could not compile `iron_diesel_middleware`.
Code is just a copy and paste from the README here. I checked the other issues and I do not appear to have duplicates of Iron.
Thanks!
Compiling with diesel 0.8 fails to typecheck. Attaching cargo log. I had a go at fixing this, but it's not clear to me what's wrong; PgConnection satisfies Connection just fine.
error[E0277]: the trait bound `diesel::pg::PgConnection: diesel::connection::Connection` is not satisfied
--> src\lib.rs:19:3
|
19 | pub pool: DieselPool,
| ^^^^^^^^^^^^^^^^^^^^ trait `diesel::pg::PgConnection: diesel::connection::Connection` not satisfied
|
= note: required because of the requirements on the impl of `r2d2::ManageConnection` for `r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>`
= note: required by `r2d2::Pool`
error[E0277]: the trait bound `diesel::pg::PgConnection: diesel::connection::Connection` is not satisfied
--> src\lib.rs:22:18
|
22 | pub struct Value(DieselPool);
| ^^^^^^^^^^^ trait `diesel::pg::PgConnection: diesel::connection::Connection` not satisfied
|
= note: required because of the requirements on the impl of `r2d2::ManageConnection` for `r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>`
= note: required by `r2d2::Pool`
error[E0277]: the trait bound `diesel::pg::PgConnection: diesel::connection::Connection` is not satisfied
--> src\lib.rs:46:6
|
46 | impl BeforeMiddleware for DieselMiddleware {
| ^^^^^^^^^^^^^^^^ trait `diesel::pg::PgConnection: diesel::connection::Connection` not satisfied
|
= note: required because of the requirements on the impl of `r2d2::ManageConnection` for `r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>`
= note: required because it appears within the type `r2d2::SharedPool<r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Arc<r2d2::SharedPool<r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>>>`
= note: required because it appears within the type `r2d2::Pool<r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Arc<r2d2::Pool<r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>>>`
= note: required because it appears within the type `DieselMiddleware`
= note: required by `iron::BeforeMiddleware`
error[E0277]: the trait bound `diesel::pg::PgConnection: diesel::connection::Connection` is not satisfied
--> src\lib.rs:75:3
|
75 | fn db_conn(&self) -> r2d2::PooledConnection<r2d2_diesel::ConnectionManager<PgConnection>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `diesel::pg::PgConnection: diesel::connection::Connection` not satisfied
|
= note: required because of the requirements on the impl of `r2d2::ManageConnection` for `r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>`
= note: required by `r2d2::PooledConnection`
error[E0277]: the trait bound `diesel::pg::PgConnection: diesel::connection::Connection` is not satisfied
--> src\lib.rs:79:3
|
79 | fn db_conn(&self) -> r2d2::PooledConnection<r2d2_diesel::ConnectionManager<PgConnection>> {
| ^ trait `diesel::pg::PgConnection: diesel::connection::Connection` not satisfied
|
= note: required because of the requirements on the impl of `r2d2::ManageConnection` for `r2d2_diesel::ConnectionManager<diesel::pg::PgConnection>`
= note: required by `r2d2::PooledConnection`
error: aborting due to 5 previous errors
error: Could not compile `iron_diesel_middleware`.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.