sansio_bootstrap/bootstrap_tcp/
bootstrap_tcp_server.rs1use super::*;
2
3pub struct BootstrapTcpServer<W> {
5 bootstrap_tcp: BootstrapTcp<W>,
6}
7
8impl<W: 'static> Default for BootstrapTcpServer<W> {
9 fn default() -> Self {
10 Self::new()
11 }
12}
13
14impl<W: 'static> BootstrapTcpServer<W> {
15 pub fn new() -> Self {
17 Self {
18 bootstrap_tcp: BootstrapTcp::new(),
19 }
20 }
21
22 pub fn max_payload_size(&mut self, max_payload_size: usize) -> &mut Self {
24 self.bootstrap_tcp.max_payload_size(max_payload_size);
25 self
26 }
27
28 pub fn pipeline(
30 &mut self,
31 pipeline_factory_fn: PipelineFactoryFn<TaggedBytesMut, W>,
32 ) -> &mut Self {
33 self.bootstrap_tcp.pipeline(pipeline_factory_fn);
34 self
35 }
36
37 pub async fn bind<A: ToSocketAddrs>(&self, addr: A) -> Result<SocketAddr, Error> {
39 self.bootstrap_tcp.bind(addr).await
40 }
41
42 pub async fn stop(&self) {
44 self.bootstrap_tcp.stop().await
45 }
46
47 pub async fn wait_for_stop(&self) {
49 self.bootstrap_tcp.wait_for_stop().await
50 }
51
52 pub async fn graceful_stop(&self) {
54 self.bootstrap_tcp.graceful_stop().await
55 }
56}