pub struct AddrIncomingConfig { /* private fields */ }
Expand description

A configuration for AddrIncoming.

Implementations

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();
}

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();
}

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();
}

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();
}

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more