Trying to import my first external crate, getting errors

Hello all, attempting to learn Rust, and am importing external create Postgres.
I have added the required information that is needed "I think". I have tried several different variants all end the same =/. Have been using the examples provided here postgres How do I fix this? (I am attempting to read the documentation, but not everything is making sense :joy:). Any/all help very much appreciated.

error[E0432]: unresolved import `postgres::Connection`
 --> src/main.rs:1:5
  |
1 | use postgres::Connection;
  |     ^^^^^^^^^^----------
  |     |         |
  |     |         help: a similar name exists in the module (notice the capitalization): `connection`
  |     no `Connection` in the root

error[E0433]: failed to resolve: use of undeclared type `TlsMode`
  --> src/main.rs:21:72
   |
21 |     let conn = Connection::connect("postgresql://rust@localhost:5433", TlsMode::None).unwrap();
   |                                                                        ^^^^^^^ use of undeclared type `TlsMode`

Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `unnamed` due to 2 previous errors
smoke@smoke:~/Rust/unnamed$ cargo run
   Compiling unnamed v0.1.0 (/home/smoke/Rust/unnamed)
error[E0432]: unresolved imports `postgres::Connection`, `postgres::TlsMode`
 --> src/main.rs:1:16
  |
1 | use postgres::{Connection, TlsMode};
  |                ^^^^^^^^^^  ^^^^^^^ no `TlsMode` in the root
  |                |
  |                no `Connection` in the root
  |                help: a similar name exists in the module (notice the capitalization): `connection`

You linked to the docs for version 0.15.2, which was released in February 2018. Probably you're using a much newer version of the crate (check your Cargo.toml and Cargo.lock files).

1 Like

Thank you, I can't believe I missed that =/

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.