Skip to content

Commit

Permalink
Manually implement Clone for QuicTransportOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Apr 6, 2024
1 parent f2c79d1 commit d70770e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.2.0-alpha.1"
version = "0.2.0-alpha.2"
edition = "2021"
license = "MPL-2.0"
repository = "https://github.com/al8n/memberlist"
Expand Down
1 change: 1 addition & 0 deletions transports/net/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ pub struct NetTransportOptions<I, A: AddressResolver<ResolvedAddress = SocketAdd
)]
metric_labels: Option<std::sync::Arc<memberlist_core::types::MetricLabels>>,
}

impl<I, A: AddressResolver<ResolvedAddress = SocketAddr>, S: StreamLayer> Clone
for NetTransportOptions<I, A, S>
where
Expand Down
2 changes: 1 addition & 1 deletion transports/quic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ rcgen = { version = "0.12", optional = true }

# s2n
s2n-quic = { version = "1.32", optional = true }
s2n-quic-transport = { version = "0.34", optional = true }
s2n-quic-transport = { version = "0.35", optional = true }

# compression
rayon = { version = "1.8", optional = true }
Expand Down
30 changes: 29 additions & 1 deletion transports/quic/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;

/// Used to configure a net transport.
#[viewit::viewit(getters(vis_all = "pub"), setters(vis_all = "pub", prefix = "with"))]
#[derive(Debug, Clone)]
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "serde",
Expand Down Expand Up @@ -185,6 +185,34 @@ pub struct QuicTransportOptions<I, A: AddressResolver<ResolvedAddress = SocketAd
metric_labels: Option<Arc<memberlist_core::types::MetricLabels>>,
}

impl<I, A: AddressResolver<ResolvedAddress = SocketAddr>, S: StreamLayer> Clone
for QuicTransportOptions<I, A, S>
where
I: Clone,
A::Options: Clone,
S::Options: Clone,
{
fn clone(&self) -> Self {
Self {
id: self.id.clone(),
bind_addresses: self.bind_addresses.clone(),
label: self.label.clone(),
resolver: self.resolver.clone(),
stream_layer: self.stream_layer.clone(),
skip_inbound_label_check: self.skip_inbound_label_check,
timeout: self.timeout,
connection_pool_cleanup_period: self.connection_pool_cleanup_period,
cidrs_policy: self.cidrs_policy.clone(),
#[cfg(feature = "compression")]
compressor: self.compressor,
#[cfg(feature = "compression")]
offload_size: self.offload_size,
#[cfg(feature = "metrics")]
metric_labels: self.metric_labels.clone(),
}
}
}

impl<I, A: AddressResolver<ResolvedAddress = SocketAddr>, S: StreamLayer>
QuicTransportOptions<I, A, S>
where
Expand Down

0 comments on commit d70770e

Please sign in to comment.