Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection example #13

Closed
victrcodes opened this issue Jun 18, 2015 · 2 comments
Closed

Connection example #13

victrcodes opened this issue Jun 18, 2015 · 2 comments

Comments

@victrcodes
Copy link

What exactly is r2d2_foodb::FooConnectionManager in the example and is there a source code of it somewhere? I tried using something like this:

let config = r2d2::Config::default();
let manager = r2d2::ConnectionManager::new("postgres://postgres:postgres@localhost/test");
let error_handler = Box::new(r2d2::LoggingErrorHandler);
let pool = Arc::new(r2d2::Pool::new(config, manager, error_handler).unwrap());

but it throws an error

src/main.rs:125:16: 125:44 error: the value of the associated type `Error` (from the trait `r2d2::ConnectionManager`) must be specified [E0191]
src/main.rs:125     let manager = r2d2::ConnectionManager::new(DB_URI);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:125:16: 125:44 error: the value of the associated type `Connection` (from the trait `r2d2::ConnectionManager`) must be specified [E0191]
src/main.rs:125     let manager = r2d2::ConnectionManager::new(DB_URI);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:125:16: 125:44 error: no associated item named `new` found for type `r2d2::ConnectionManager` in the current scope
src/main.rs:125     let manager = r2d2::ConnectionManager::new(DB_URI);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 3 previous errors
@sfackler
Copy link
Owner

r2d2_foodb doesn't exist - it's an imaginary crate used for that example.

ConnectionManager is a trait - you can't instantiate it directly. See r2d2_postgres for postgres support as well as a code example.

@victrcodes
Copy link
Author

Sorry, my bad, just got confused by these similar looking repos. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants