Struct Builder

Source
pub struct Builder<Ex> { /* private fields */ }
Available on crate feature client and (crate features http1 or http2) only.
Expand description

A builder to configure an HTTP connection.

After setting options, the builder is used to create a handshake future.

Note: The default values of options are not considered stable. They are subject to change at any time.

Implementations§

Source§

impl<Ex> Builder<Ex>
where Ex: Clone,

Source

pub fn new(exec: Ex) -> Builder<Ex>

Creates a new connection builder.

Source

pub fn timer<M>(&mut self, timer: M) -> &mut Builder<Ex>
where M: Timer + Send + Sync + 'static,

Provide a timer to execute background HTTP2 tasks.

Source

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

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

Passing None will do nothing.

If not set, hyper will use a default.

Source

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

Sets the max connection-level flow control for HTTP2

Passing None will do nothing.

If not set, hyper will use a default.

Source

pub fn adaptive_window(&mut self, enabled: bool) -> &mut 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(&mut self, sz: impl Into<Option<u32>>) -> &mut Self

Sets the maximum frame size to use for HTTP2.

Passing None will do nothing.

If not set, hyper will use a default.

Source

pub fn keep_alive_interval( &mut self, interval: impl Into<Option<Duration>>, ) -> &mut 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(&mut self, timeout: Duration) -> &mut 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(&mut self, enabled: bool) -> &mut 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 max_concurrent_reset_streams(&mut self, max: usize) -> &mut Self

Sets the maximum number of HTTP2 concurrent locally reset streams.

See the documentation of h2::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(&mut self, max: usize) -> &mut 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 handshake<T, B>( &self, io: T, ) -> impl Future<Output = Result<(SendRequest<B>, Connection<T, B, Ex>)>>
where T: Read + Write + Unpin + 'static, B: Body + 'static, B::Data: Send, B::Error: Into<Box<dyn Error + Send + Sync>>, Ex: Http2ClientConnExec<B, T> + Unpin,

Constructs a connection with the configured options and IO. See client::conn for more.

Note, if Connection is not await-ed, SendRequest will do nothing.

Trait Implementations§

Source§

impl<Ex: Clone> Clone for Builder<Ex>

Source§

fn clone(&self) -> Builder<Ex>

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<Ex: Debug> Debug for Builder<Ex>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Ex> Freeze for Builder<Ex>
where Ex: Freeze,

§

impl<Ex> !RefUnwindSafe for Builder<Ex>

§

impl<Ex> Send for Builder<Ex>
where Ex: Send,

§

impl<Ex> Sync for Builder<Ex>
where Ex: Sync,

§

impl<Ex> Unpin for Builder<Ex>
where Ex: Unpin,

§

impl<Ex> !UnwindSafe for Builder<Ex>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

Source§

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

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