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

A configuration for AddrIncoming.

Implementations§

source§

impl AddrIncomingConfig

source

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
28
29
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)))
        .tcp_keepalive_interval(Some(Duration::from_secs(1)))
        .tcp_keepalive_retries(Some(1))
        .build();

    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    println!("listening on {}", addr);
    hyper_server::bind(addr)
        .addr_incoming_config(config)
        .serve(app.into_make_service())
        .await
        .unwrap();
}
source

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 20)
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)))
        .tcp_keepalive_interval(Some(Duration::from_secs(1)))
        .tcp_keepalive_retries(Some(1))
        .build();

    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    println!("listening on {}", addr);
    hyper_server::bind(addr)
        .addr_incoming_config(config)
        .serve(app.into_make_service())
        .await
        .unwrap();
}
source

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
28
29
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)))
        .tcp_keepalive_interval(Some(Duration::from_secs(1)))
        .tcp_keepalive_retries(Some(1))
        .build();

    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    println!("listening on {}", addr);
    hyper_server::bind(addr)
        .addr_incoming_config(config)
        .serve(app.into_make_service())
        .await
        .unwrap();
}
source

pub fn tcp_keepalive(&mut self, val: Option<Duration>) -> &mut Self

Set how often to send TCP keepalive probes.

By default TCP keepalive probes is disabled.

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
28
29
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)))
        .tcp_keepalive_interval(Some(Duration::from_secs(1)))
        .tcp_keepalive_retries(Some(1))
        .build();

    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    println!("listening on {}", addr);
    hyper_server::bind(addr)
        .addr_incoming_config(config)
        .serve(app.into_make_service())
        .await
        .unwrap();
}
source

pub fn tcp_keepalive_interval(&mut self, val: Option<Duration>) -> &mut Self

Set the duration between two successive TCP keepalive retransmissions, if acknowledgement to the previous keepalive transmission is not received.

Default is no interval.

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
28
29
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)))
        .tcp_keepalive_interval(Some(Duration::from_secs(1)))
        .tcp_keepalive_retries(Some(1))
        .build();

    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    println!("listening on {}", addr);
    hyper_server::bind(addr)
        .addr_incoming_config(config)
        .serve(app.into_make_service())
        .await
        .unwrap();
}
source

pub fn tcp_keepalive_retries(&mut self, val: Option<u32>) -> &mut Self

Set the number of retransmissions to be carried out before declaring that remote end is not available.

Default is no retry.

Examples found in repository?
examples/configure_addr_incoming.rs (line 19)
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)))
        .tcp_keepalive_interval(Some(Duration::from_secs(1)))
        .tcp_keepalive_retries(Some(1))
        .build();

    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    println!("listening on {}", addr);
    hyper_server::bind(addr)
        .addr_incoming_config(config)
        .serve(app.into_make_service())
        .await
        .unwrap();
}
source

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
28
29
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)))
        .tcp_keepalive_interval(Some(Duration::from_secs(1)))
        .tcp_keepalive_retries(Some(1))
        .build();

    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    println!("listening on {}", addr);
    hyper_server::bind(addr)
        .addr_incoming_config(config)
        .serve(app.into_make_service())
        .await
        .unwrap();
}

Trait Implementations§

source§

impl Clone for AddrIncomingConfig

source§

fn clone(&self) -> AddrIncomingConfig

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for AddrIncomingConfig

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for AddrIncomingConfig

source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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