预期结构 `rustls::client::ClientConfig`,找到结构 `ClientConfig`

expected struct `rustls::client::ClientConfig`, found struct `ClientConfig`

当我尝试使用这个函数时出现这个错误https://docs.rs/awc/2.0.3/awc/struct.Connector.html#method.rustls

async fn get_client_config() -> rustls::client::ClientConfig {
    let root_certs = rustls::RootCertStore::empty();
    rustls::ClientConfig::builder()
        .with_safe_defaults()
        .with_root_certificates(root_certs)
        .with_no_client_auth()
}

async fn get_client() -> Client {
    let client_config: rustls::client::ClientConfig = get_client_config().await;
    // Error in next line.
    let connector = Connector::new().rustls(client_config).finish(); 
    ClientBuilder::new().connector(connector).finish()
}
error[E0308]: mismatched types
  --> src/main.rs:31:59
   |
31 |     let connector = awc::Connector::new().rustls(Arc::new(client_config)).finish();
   |                                                           ^^^^^^^^^^^^^ expected struct `rustls::client::ClientConfig`, found struct `ClientConfig`
[dependencies]
awc = "2.0.3"
actix-web = "3.3.2"
futures-util = "0.3.17"
rustls = "0.20.1"                                                                                                                                    
actix-http = {version="2.2.1", features = ["rustls"]}

awc 2.0.3 需要 rustls 0.18.1,正如您在文档中跟随 link 到 ClientConfig 所见。但是,您正在尝试使用 rustls 0.20.1。从编译器的角度来看,这两个版本是两个截然不同的、完全独立的 crate,它们里面的类型,即使定义完全相同,也是互不兼容的。

因此解决方案很简单 - 将 Cargo.toml 中 rustls 的版本更改为 awc 接受的版本,即 0.18.1