Expose cid generator customization API in endpoint builder
use std::{io, net::SocketAddr, sync::Arc};
-use proto::generic::{ClientConfig, EndpointConfig, ServerConfig};
+use proto::{
+ generic::{ClientConfig, EndpointConfig, ServerConfig},
+ ConnectionIdGenerator,
+};
use thiserror::Error;
use tracing::error;
@@ -100,6 +103,17 @@ where
self.default_client_config = config;
self
}
+
+ /// Use a customized cid generator factory in the endpoint
+ pub fn connection_id_generator<
+ F: Fn() -> Box<dyn ConnectionIdGenerator> + Send + Sync + 'static,
+ >(
+ &mut self,
+ factory: F,
+ ) -> &mut Self {
+ self.config.cid_generator(factory);
+ self
+ }
}
impl<S> Default for EndpointBuilder<S>
