Git Product home page Git Product logo

iron-diesel-middleware's People

Contributors

alexw-gh avatar darayus avatar gyrosofwar avatar jacobh avatar nrdmn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

iron-diesel-middleware's Issues

No longer builds with diesel 0.8

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`.

Use of std::sync::Arc

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.

Having trouble building this into my application

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.