use super::*;
pub struct BootstrapUdpServer<W> {
bootstrap_udp: BootstrapUdp<W>,
}
impl<W: 'static> Default for BootstrapUdpServer<W> {
fn default() -> Self {
Self::new()
}
}
impl<W: 'static> BootstrapUdpServer<W> {
pub fn new() -> Self {
Self {
bootstrap_udp: BootstrapUdp::new(),
}
}
pub fn max_payload_size(&mut self, max_payload_size: usize) -> &mut Self {
self.bootstrap_udp.max_payload_size(max_payload_size);
self
}
pub fn pipeline(
&mut self,
pipeline_factory_fn: PipelineFactoryFn<TaggedBytesMut, W>,
) -> &mut Self {
self.bootstrap_udp.pipeline(pipeline_factory_fn);
self
}
pub async fn bind<A: AsyncToSocketAddrs>(&mut self, addr: A) -> Result<SocketAddr, Error> {
let local_addr = self.bootstrap_udp.bind(addr).await?;
let peer_addr: Option<SocketAddr> = None;
self.bootstrap_udp.connect(peer_addr).await?;
Ok(local_addr)
}
pub async fn stop(&self) {
self.bootstrap_udp.stop().await
}
pub async fn wait_for_stop(&self) {
self.bootstrap_udp.wait_for_stop().await
}
pub async fn graceful_stop(&self) {
self.bootstrap_udp.graceful_stop().await
}
}