私は構造体を返すbuild()関数を持つモジュールの束を使用してきました。ただし、それらをバンドルするために独自の「スーパー」構造体を作成しようとすると、エラーが発生しますmodule `xxx` is private rustc(E0603)
。特性がある場合、個々の変数をパラメーターとして渡すことはできますが、構造体用にそれを定義/ボックス化する方法を理解できません。
私が打っているこの現在の例は、ハイパークライアントを作成するときです。
// Error due to privacy and cannot use the trait to define the member type
// Both the "hyper_rustls::connector" and "hyper::client::connect::http" modules are private.
struct SecureClient {
client: hyper::client::Client<
hyper_rustls::connector::HttpsConnector<hyper::client::connect::http::HttpConnector>>
}
// Works, but passing the client everywhere as an individual variable is not realistic.
fn use_client(client: hyper::client::Client<impl hyper::client::connect::Connect>) -> () {
()
}
let https_conn = hyper_rustls::HttpsConnector::new(4);
let client: hyper::client::Client<_, hyper::Body> = hyper::Client::builder().build(https_conn);
Rustに慣れていないので、自分がやろうとしていることに対して適切な専門用語が何であるかを理解するのに苦労しています。これに関するドキュメントまたはコード例へのリンクをいただければ幸いです。
ありがとう
私はあなたが何をしたいのかわからないんだけど、あなたは、公共の再輸出を使用することができるhyper_rustls::HttpsConnector
代わりに、プライベートのhyper_rustls::connector::HttpsConnector
と公共の再輸出hyper::client::HttpConnector
の代わりにプライベートhyper::client::connect::http::HttpConnector
。再エクスポートについては、https://doc.rust-lang.org/book/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#re-exporting-namesで読むことができます。 -with-pub-use
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加