Struct axum_server::AddrIncomingConfig
source · [−]pub struct AddrIncomingConfig { /* private fields */ }Expand description
A configuration for AddrIncoming.
Implementations
sourceimpl AddrIncomingConfig
impl AddrIncomingConfig
sourcepub fn new() -> AddrIncomingConfig
pub fn new() -> AddrIncomingConfig
Creates a default AddrIncoming config.
Examples found in repository?
examples/configure_addr_incoming.rs (line 14)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let config = AddrIncomingConfig::new()
.tcp_nodelay(true)
.tcp_sleep_on_accept_errors(true)
.tcp_keepalive(Some(Duration::from_secs(32)))
.build();
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server::bind(addr)
.addr_incoming_config(config)
.serve(app.into_make_service())
.await
.unwrap();
}sourcepub fn build(&mut self) -> Self
pub fn build(&mut self) -> Self
Builds the config, creating an owned version of it.
Examples found in repository?
examples/configure_addr_incoming.rs (line 18)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let config = AddrIncomingConfig::new()
.tcp_nodelay(true)
.tcp_sleep_on_accept_errors(true)
.tcp_keepalive(Some(Duration::from_secs(32)))
.build();
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server::bind(addr)
.addr_incoming_config(config)
.serve(app.into_make_service())
.await
.unwrap();
}sourcepub fn tcp_sleep_on_accept_errors(&mut self, val: bool) -> &mut Self
pub fn tcp_sleep_on_accept_errors(&mut self, val: bool) -> &mut Self
Set whether to sleep on accept errors, to avoid exhausting file descriptor limits.
Default is true.
Examples found in repository?
examples/configure_addr_incoming.rs (line 16)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let config = AddrIncomingConfig::new()
.tcp_nodelay(true)
.tcp_sleep_on_accept_errors(true)
.tcp_keepalive(Some(Duration::from_secs(32)))
.build();
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server::bind(addr)
.addr_incoming_config(config)
.serve(app.into_make_service())
.await
.unwrap();
}sourcepub fn tcp_keepalive(&mut self, val: Option<Duration>) -> &mut Self
pub fn tcp_keepalive(&mut self, val: Option<Duration>) -> &mut Self
Set how often to send TCP keepalive probes.
Default is false.
Examples found in repository?
examples/configure_addr_incoming.rs (line 17)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let config = AddrIncomingConfig::new()
.tcp_nodelay(true)
.tcp_sleep_on_accept_errors(true)
.tcp_keepalive(Some(Duration::from_secs(32)))
.build();
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server::bind(addr)
.addr_incoming_config(config)
.serve(app.into_make_service())
.await
.unwrap();
}sourcepub fn tcp_nodelay(&mut self, val: bool) -> &mut Self
pub fn tcp_nodelay(&mut self, val: bool) -> &mut Self
Set the value of TCP_NODELAY option for accepted connections.
Default is false.
Examples found in repository?
examples/configure_addr_incoming.rs (line 15)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
async fn main() {
let app = Router::new().route("/", get(|| async { "Hello, world!" }));
let config = AddrIncomingConfig::new()
.tcp_nodelay(true)
.tcp_sleep_on_accept_errors(true)
.tcp_keepalive(Some(Duration::from_secs(32)))
.build();
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum_server::bind(addr)
.addr_incoming_config(config)
.serve(app.into_make_service())
.await
.unwrap();
}Trait Implementations
sourceimpl Clone for AddrIncomingConfig
impl Clone for AddrIncomingConfig
sourcefn clone(&self) -> AddrIncomingConfig
fn clone(&self) -> AddrIncomingConfig
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for AddrIncomingConfig
impl Debug for AddrIncomingConfig
Auto Trait Implementations
impl RefUnwindSafe for AddrIncomingConfig
impl Send for AddrIncomingConfig
impl Sync for AddrIncomingConfig
impl Unpin for AddrIncomingConfig
impl UnwindSafe for AddrIncomingConfig
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more