How to use pub struct inside a private mod?

When testing tokio-quiche by building an example, I create a trait, struct

trait Ping {
  fn listen<H: DriverHooks>(self, fn(H3Controller<H>) -> ());
} 

struct Server {
  address: tokionet::net::UdpSocket,
}

When implementing the trait for the struct, I encounter a problem where a parameterized type inside a returned value actually is located inside a private module. Therefore, while attempting to fix cannot find trait ... in this scope error, I can not simply use tokio_quiche::http3::driver::server::DriverHooks as import statement. Rust will complains module server is private, but without use statement, Rust complains can't find trait in this scope. How to fix this? Thanks.

The code snippet is as below

impl Ping for Server {
  fn listen<H: DriverHooks>(self, f: fn(H3Controller<H>) -> ()) {
    ... // the code to create accept_stream is the same as the example provided by tokio_quiche
    while let Some(conn) = accept_stream.next().await {
        let (driver, controller) = ServerH3Driver::new(Http3Settings::default()); // controller is H3Cotroller<ServerHooks> type
        conn?.start(driver);
        tokio::spawn(f(controller)); 
    }
  }
}

Example provided by tokio-quiche: quiche/tokio-quiche at master · cloudflare/quiche · GitHub

if you have outer_module that accesses a inner_module with a private_ineer_module
you can do pub use private_inner_module::type_you_want_exposed and in inner module and that will allow you to access it from the outside via inner_module::type

Please correct me if I misunderstand it.

I try adding pub use tokio_quiche::http3::driver::server::DriverHooks; to the source file that refers to DriversHooks

but cargo build still throws

4 | pub use tokio_quiche::http3::driver::server::DriverHooks;
   |                                      ^^^^^^ private module

And I do not permission to change tokio_quiche crate as it is developed by cloudflare, so I think I can't re-export pub use tokio_quiche::...DriverHooks in server.rs file. Any workaround? Thanks.

It is intentionally not possible to access DriverHooks yourself:

For a server, you may want to hard code the ServerHooks type instead (or to be precise the ServerH3Controller type alias that is public).

Ah, ok. But if so, how do I define the functional pointer f: fn(H3Controller<ServerHooks>) -> () that passes as argument to the function fn listen()?

The listen() function can not be hard coded with e.g. fn listen(..., f: fn(H3Controller<ServerHooks>) -> ()) or fn listen(..., f: fn(H3Ccontroller<H>) -> ()) where H: ServerHooks. These would throw this type/ trait is not in scope because ServerHooks is in private module.

You use the H3ServerController type alias instead of H3Controller<ServerHook>. Looks like you can create one using ServerH3Driver::new(settings). new() returns a tuple of ServerH3Driver and H3ServerController.

Ok. It looks like there is a tokio_quiche::ServerH3Controller, which is an alias for H3Controller type. Thanks for the advice!