BiagioFesta / wtransport

Async-friendly WebTransport implementation in Rust
Apache License 2.0
402 stars 27 forks source link

Please implement the Clone trait for the Certificate #89

Closed bugnano closed 10 months ago

bugnano commented 10 months ago

I'd like to be able to do the following:

            let certificate = Certificate::load(&certfile, &keyfile).await?;

            let endpoints = addrs_iter
                .map(|bind_address| {
                    let config = ServerConfig::builder()
                        .with_bind_address(bind_address)
                        .with_certificate(certificate.clone())
                        .keep_alive_interval(Some(Duration::from_secs(3)))
                        .build();

                    Ok((Endpoint::server(config)?, bind_address))
                })
                .collect::<Result<Vec<(Endpoint<Server>, SocketAddr)>, io::Error>>()?;

So that I can load the certificates from disk only once, and be able to create multiple endpoints with the same certificates.

I was thinking that if the Certificate struct implements the Clone trait, then this would be possible, right?

BiagioFesta commented 10 months ago

Definitely! Thanks for the feedback