lingdu1234 / sea_orm_casbin_adapter

sea_orm_casbin_adapter
MIT License
10 stars 1 forks source link

In Cargo.toml "runtime-async-std" is enabled for casbin and "runtime-tokio-native-tls" for sea-orm #1

Open apps4uco opened 2 years ago

apps4uco commented 2 years ago

Hi, In Cargo.toml "runtime-async-std" is enabled for casbin and "runtime-tokio-native-tls" for sea-orm is this a mistake?

[dependencies]
async-trait = "0.1.51"
casbin = {version = "2.0.9", default-features = false, features = ["runtime-async-std", "logging", "incremental"]}
tokio = {version = "1.14.0", features = ["fs", "io-util", "rt-multi-thread", "macros"]}

[dependencies.sea-orm]
default-features = false
features = ["macros", "runtime-tokio-native-tls"]
version = "0.5.0"

As I understand it should be one or the other.

Also would it be possible to choose the runtime, I previously used tokio with rust-tls in my project and was forced to change it to "runtime-tokio-native-tls" by the inclusion of this crate.

As both (incompatible?) features are enabled I get a compile error in casbin-2.0.9/src/adapter/file_adapter.rs:20:10

error[E0252]: the name `IoError` is defined multiple times
  --> ***** .cargo/registry/src/-ba5a813e27fafabc/casbin-2.0.9/src/adapter/file_adapter.rs:20:10
   |
13 |     io::{BufReader, Error as IoError, ErrorKind},
   |                     ---------------- previous import of the type `IoError` here
...
20 |     io::{Error as IoError, ErrorKind},
   |          ^^^^^^^^^^^^^^^^--
   |          |
   |          `IoError` reimported here
   |          help: remove unnecessary import

Thanks

hsluoyz commented 2 years ago

@psiace

PsiACE commented 2 years ago

I suggest you use the tokio runtime instead of async-std

apps4uco commented 2 years ago

I suggest you use the tokio runtime instead of async-std

That is what I am trying to do but get a compilation error because in the sea_orm_casbin_adapter crates Cargo.toml it specifies async-std as the runtime for casbin.

Would it be possible to have features to configure the desired runtime in this projects Cargo.toml.

hsluoyz commented 2 years ago

@PsiACE @lingdu1234

lingdu1234 commented 2 years ago

just updated the version 3.0.1 you can try it ,may be works,in the version 3.0 enabled no default run time,the adapter'run time same with the sea-orm

[dependencies]
sea_orm_casbin_adapter = {version = "0.3", features = ["mysql", "runtime-tokio-native-tls"]}
sea-orm = {version = "0.6.0", default-features = false, features = ["sqlx-mysql", "macros", "runtime-tokio-native-tls"]}

or

[dependencies]
sea_orm_casbin_adapter = {version = "0.3", features = ["mysql", "runtime-tokio-rustls"]}

[dependencies.sea-orm]
default-features = false
features = ["macros", "runtime-tokio-rustls"]
version = "0.6.0"

[features]
default = ["postgres", "mysql"]
mysql = ["sea-orm/sqlx-mysql"]
postgres = ["sea-orm/sqlx-postgres"]
sqlite = ["sea-orm/sqlx-sqlite"]

@apps4uco @hsluoyz