prisma / tiberius

TDS 7.2+ (Microsoft SQL Server) driver for Rust
Apache License 2.0
321 stars 119 forks source link

The name `create_tls_stream` is defined multiple times #242

Closed westernwontons closed 2 years ago

westernwontons commented 2 years ago

I'm taking a crack at a Tauri project that uses prisma-client-rust. I was told to create a cargo workspace for this to work and to my best knowledge, I have done so. When I attempt to build either prisma-client-rust or tauri by running cargo --bin src-prisma -- or cargo tauri dev, respectively, I'm greeted by this error.

error[E0428]: the name `create_tls_stream` is defined multiple times
  --> /Users/nagybotond/.cargo/registry/src/github.com-1ecc6299db9ec823/tiberius-0.9.5/src/client/tls_stream.rs:39:1
   |
31 | / pub(crate) async fn create_tls_stream<S: AsyncRead + AsyncWrite + Unpin + Send>(
32 | |     config: &Config,
33 | |     stream: S,
34 | | ) -> crate::Result<TlsStream<S>> {
35 | |     native_tls_stream::create_tls_stream(config, stream).await
36 | | }
   | |_- previous definition of the value `create_tls_stream` here
...
39 | / pub(crate) async fn create_tls_stream<S: AsyncRead + AsyncWrite + Unpin + Send>(
40 | |     config: &Config,
41 | |     stream: S,
42 | | ) -> crate::Result<TlsStream<S>> {
43 | |     opentls_tls_stream::create_tls_stream(config, stream).await
44 | | }
   | |_^ `create_tls_stream` redefined here
   |
   = note: `create_tls_stream` must be defined only once in the value namespace of this module

error[E0252]: the name `TlsStream` is defined multiple times
  --> /Users/nagybotond/.cargo/registry/src/github.com-1ecc6299db9ec823/tiberius-0.9.5/src/client/tls_stream.rs:20:16
   |
14 | pub(crate) use native_tls_stream::TlsStream;
   |                ---------------------------- previous import of the type `TlsStream` here
...
20 | pub(crate) use opentls_tls_stream::TlsStream;
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `TlsStream` reimported here
   |
   = note: `TlsStream` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
   |
20 | pub(crate) use opentls_tls_stream::TlsStream as OtherTlsStream;
   |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0308]: mismatched types
  --> /Users/nagybotond/.cargo/registry/src/github.com-1ecc6299db9ec823/tiberius-0.9.5/src/client/tls_stream.rs:43:5
   |
43 |     opentls_tls_stream::create_tls_stream(config, stream).await
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `async_native_tls::TlsStream`, found struct `opentls::async_io::TlsStream`
   |
   = note: expected enum `std::result::Result<async_native_tls::TlsStream<S>, _>`
              found enum `std::result::Result<opentls::async_io::TlsStream<S>, _>`

Some errors have detailed explanations: E0252, E0308, E0428.
For more information about an error, try `rustc --explain E0252`.
error: could not compile `tiberius` due to 3 previous errors

My project structure is the following:

.
├── Cargo.lock
├── Cargo.toml
├── dist
├── next-env.d.ts
├── next.config.js
├── package.json
├── pnpm-lock.yaml
├── postcss.config.js
├── README.md
├── src
│  ├── assets
│  ├── components
│  │  └── ticket
│  ├── pages
│  └── style.css
├── src-prisma
│  ├── Cargo.toml
│  ├── rustfmt.toml
│  └── src
│     └── main.rs
├── src-tauri
│  ├── build.rs
│  ├── Cargo.toml
│  ├── icons
│  │  └── icon.icns
│  ├── rustfmt.toml
│  ├── src
│  │  └── main.rs
│  └── tauri.conf.json
├── tailwind.config.js
└── tsconfig.json

Where: The top-level Cargo.toml has the following content:

[workspace]
members = [
  'src-tauri',
  'src-prisma'
]

[profile.release]
strip = true
panic = "abort" # Strip expensive panic clean-up logic
codegen-units = 1 # Compile crates one after another so the compiler can optimize better
lto = true # Enables link to optimizations
opt-level = "s" # Optimize for binary size

The Cargo.toml in src-prisma has the following content:

[package]
name = "src-prisma"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust", tag = "0.6.0" }

The Cargo.toml in src-tauri has the following content:

[package]
name = "ticketr"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
edition = "2021"
rust-version = "1.57"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
tauri-build = { version = "1.0.0", features = [] }

[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0", features = ["api-all"] }
prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust", tag = "0.6.0" }

[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
default = [ "custom-protocol" ]
# this feature is used used for production builds where `devPath` points to the filesystem
# DO NOT remove this
custom-protocol = [ "tauri/custom-protocol" ]

The project is available at the following url: https://github.com/westernwontons/ticketr

If I'm being a dumdum please let me know.

westernwontons commented 2 years ago

I was missing resolver = "2" from the top level Cargo.toml. I was being a dumdum.