diff --git a/tonic/src/transport/server/mod.rs b/tonic/src/transport/server/mod.rs index 6b55c6965..357e0e0a1 100644 --- a/tonic/src/transport/server/mod.rs +++ b/tonic/src/transport/server/mod.rs @@ -154,6 +154,7 @@ impl Server { /// Configure TLS for this server. #[cfg(feature = "tls")] #[cfg_attr(docsrs, doc(cfg(feature = "tls")))] + #[must_use] pub fn tls_config(self, tls_config: ServerTlsConfig) -> Result { Ok(Server { tls: Some(tls_config.tls_acceptor().map_err(Error::from_source)?), @@ -171,6 +172,7 @@ impl Server { /// # let builder = Server::builder(); /// builder.concurrency_limit_per_connection(32); /// ``` + #[must_use] pub fn concurrency_limit_per_connection(self, limit: usize) -> Self { Server { concurrency_limit: Some(limit), @@ -189,6 +191,7 @@ impl Server { /// # let builder = Server::builder(); /// builder.timeout(Duration::from_secs(30)); /// ``` + #[must_use] pub fn timeout(self, timeout: Duration) -> Self { Server { timeout: Some(timeout), @@ -202,6 +205,7 @@ impl Server { /// Default is 65,535 /// /// [spec]: https://http2.github.io/http2-spec/#SETTINGS_INITIAL_WINDOW_SIZE + #[must_use] pub fn initial_stream_window_size(self, sz: impl Into>) -> Self { Server { init_stream_window_size: sz.into(), @@ -212,6 +216,7 @@ impl Server { /// Sets the max connection-level flow control for HTTP2 /// /// Default is 65,535 + #[must_use] pub fn initial_connection_window_size(self, sz: impl Into>) -> Self { Server { init_connection_window_size: sz.into(), @@ -225,6 +230,7 @@ impl Server { /// Default is no limit (`None`). /// /// [spec]: https://http2.github.io/http2-spec/#SETTINGS_MAX_CONCURRENT_STREAMS + #[must_use] pub fn max_concurrent_streams(self, max: impl Into>) -> Self { Server { max_concurrent_streams: max.into(), @@ -241,6 +247,7 @@ impl Server { /// /// Default is no HTTP2 keepalive (`None`) /// + #[must_use] pub fn http2_keepalive_interval(self, http2_keepalive_interval: Option) -> Self { Server { http2_keepalive_interval, @@ -255,6 +262,7 @@ impl Server { /// /// Default is 20 seconds. /// + #[must_use] pub fn http2_keepalive_timeout(self, http2_keepalive_timeout: Option) -> Self { Server { http2_keepalive_timeout, @@ -270,6 +278,7 @@ impl Server { /// /// Default is no keepalive (`None`) /// + #[must_use] pub fn tcp_keepalive(self, tcp_keepalive: Option) -> Self { Server { tcp_keepalive, @@ -278,6 +287,7 @@ impl Server { } /// Set the value of `TCP_NODELAY` option for accepted connections. Enabled by default. + #[must_use] pub fn tcp_nodelay(self, enabled: bool) -> Self { Server { tcp_nodelay: enabled, @@ -290,6 +300,7 @@ impl Server { /// Passing `None` will do nothing. /// /// If not set, will default from underlying transport. + #[must_use] pub fn max_frame_size(self, frame_size: impl Into>) -> Self { Server { max_frame_size: frame_size.into(), @@ -305,6 +316,7 @@ impl Server { /// return confusing (but correct) protocol errors. /// /// Default is `false`. + #[must_use] pub fn accept_http1(self, accept_http1: bool) -> Self { Server { accept_http1, @@ -313,6 +325,7 @@ impl Server { } /// Intercept inbound headers and add a [`tracing::Span`] to each response future. + #[must_use] pub fn trace_fn(self, f: F) -> Self where F: Fn(&http::Request<()>) -> tracing::Span + Send + Sync + 'static,