Skip to main content

Http2OptionsBuilder

Struct Http2OptionsBuilder 

Source
pub struct Http2OptionsBuilder { /* private fields */ }
Expand description

Builder for Http2Options.

Implementations§

Source§

impl Http2OptionsBuilder

Source

pub fn initial_window_size(self, sz: impl Into<Option<u32>>) -> Self

Sets the SETTINGS_INITIAL_WINDOW_SIZE option for HTTP2 stream-level flow control.

Passing None will do nothing.

If not set, crate::core: will use a default.

Source

pub fn initial_connection_window_size(self, sz: impl Into<Option<u32>>) -> Self

Sets the max connection-level flow control for HTTP2

Passing None will do nothing.

If not set, crate::core: will use a default.

Source

pub fn initial_max_send_streams(self, initial: impl Into<Option<usize>>) -> Self

Sets the initial maximum of locally initiated (send) streams.

This value will be overwritten by the value included in the initial SETTINGS frame received from the peer as part of a connection preface.

Passing None will do nothing.

If not set, crate::core: will use a default.

Source

pub fn initial_stream_id(self, id: impl Into<Option<u32>>) -> Self

Sets the initial stream id for the connection.

Source

pub fn adaptive_window(self, enabled: bool) -> Self

Sets whether to use an adaptive flow control.

Enabling this will override the limits set in initial_stream_window_size and initial_connection_window_size.

Source

pub fn max_frame_size(self, sz: impl Into<Option<u32>>) -> Self

Sets the maximum frame size to use for HTTP2.

Default is currently 16KB, but can change.

Source

pub fn max_header_list_size(self, max: u32) -> Self

Sets the max size of received header frames.

Default is currently 16KB, but can change.

Source

pub fn header_table_size(self, size: impl Into<Option<u32>>) -> Self

Sets the header table size.

This setting informs the peer of the maximum size of the header compression table used to encode header blocks, in octets. The encoder may select any value equal to or less than the header table size specified by the sender.

The default value of crate h2 is 4,096.

Source

pub fn max_concurrent_streams(self, max: impl Into<Option<u32>>) -> Self

Sets the maximum number of concurrent streams.

The maximum concurrent streams setting only controls the maximum number of streams that can be initiated by the remote peer. In other words, when this setting is set to 100, this does not limit the number of concurrent streams that can be created by the caller.

It is recommended that this value be no smaller than 100, so as to not unnecessarily limit parallelism. However, any value is legal, including 0. If max is set to 0, then the remote will not be permitted to initiate streams.

Note that streams in the reserved state, i.e., push promises that have been reserved but the stream has not started, do not count against this setting.

Also note that if the remote does exceed the value set here, it is not a protocol level error. Instead, the h2 library will immediately reset the stream.

See Section 5.1.2 in the HTTP/2 spec for more details.

Source

pub fn keep_alive_interval(self, interval: impl Into<Option<Duration>>) -> Self

Sets an interval for HTTP2 Ping frames should be sent to keep a connection alive.

Pass None to disable HTTP2 keep-alive.

Default is currently disabled.

Source

pub fn keep_alive_timeout(self, timeout: Duration) -> Self

Sets a timeout for receiving an acknowledgement of the keep-alive ping.

If the ping is not acknowledged within the timeout, the connection will be closed. Does nothing if keep_alive_interval is disabled.

Default is 20 seconds.

Source

pub fn keep_alive_while_idle(self, enabled: bool) -> Self

Sets whether HTTP2 keep-alive should apply while the connection is idle.

If disabled, keep-alive pings are only sent while there are open request/responses streams. If enabled, pings are also sent when no streams are active. Does nothing if keep_alive_interval is disabled.

Default is false.

Source

pub fn enable_push(self, opt: bool) -> Self

Enables and disables the push feature for HTTP2.

Passing None will do nothing.

Source

pub fn enable_connect_protocol(self, opt: bool) -> Self

Sets the enable connect protocol.

Source

pub fn no_rfc7540_priorities(self, opt: bool) -> Self

Disable RFC 7540 Stream Priorities (set to true to disable). [RFC 9218]: https://www.rfc-editor.org/rfc/rfc9218.html#section-2.1

Source

pub fn max_concurrent_reset_streams(self, max: usize) -> Self

Sets the maximum number of HTTP2 concurrent locally reset streams.

See the documentation of http2::client::Builder::max_concurrent_reset_streams for more details.

The default value is determined by the h2 crate.

Source

pub fn max_send_buf_size(self, max: usize) -> Self

Set the maximum write buffer size for each HTTP/2 stream.

Default is currently 1MB, but may change.

§Panics

The value must be no larger than u32::MAX.

Source

pub fn max_pending_accept_reset_streams( self, max: impl Into<Option<usize>>, ) -> Self

Configures the maximum number of pending reset streams allowed before a GOAWAY will be sent.

See https://github.com/hyperium/hyper/issues/2877 for more information.

Source

pub fn headers_stream_dependency<T>(self, stream_dependency: T) -> Self

Sets the stream dependency and weight for the outgoing HEADERS frame.

This configures the priority of the stream by specifying its dependency and weight, as defined by the HTTP/2 priority mechanism. This can be used to influence how the server allocates resources to this stream relative to others.

Source

pub fn headers_pseudo_order<T>(self, headers_pseudo_order: T) -> Self
where T: Into<Option<PseudoOrder>>,

Sets the HTTP/2 pseudo-header field order for outgoing HEADERS frames.

This determines the order in which pseudo-header fields (such as :method, :scheme, etc.) are encoded in the HEADERS frame. Customizing the order may be useful for interoperability or testing purposes.

Source

pub fn settings_order<T>(self, settings_order: T) -> Self

Sets the order of settings parameters in the initial SETTINGS frame.

This determines the order in which settings are sent during the HTTP/2 handshake. Customizing the order may be useful for testing or protocol compliance.

Source

pub fn priorities<T>(self, priorities: T) -> Self
where T: Into<Option<Priorities>>,

Sets the list of PRIORITY frames to be sent immediately after the connection is established, but before the first request is sent.

This allows you to pre-configure the HTTP/2 stream dependency tree by specifying a set of PRIORITY frames that will be sent as part of the connection preface. This can be useful for optimizing resource allocation or testing custom stream prioritization strategies.

Each Priority in the list must have a valid (non-zero) stream ID. Any priority with a stream ID of zero will be ignored.

Source

pub fn build(self) -> Http2Options

Builds the Http2Options instance.

Trait Implementations§

Source§

impl Debug for Http2OptionsBuilder

Source§

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

Formats the value using the given formatter. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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