Struct Builder
pub struct Builder<E> { /* private fields */ }
Http1 or Http2 connection builder.
Implementations
impl<E> Builder<E>
fn new(executor: E) -> SelfCreate a new auto connection builder.
executorparameter should be a type that implementsExecutortrait.Example
use ; new;fn http1(&mut self) -> Http1Builder<'_, E>Http1 configuration.
fn http2(&mut self) -> Http2Builder<'_, E>Http2 configuration.
fn http2_only(self) -> SelfOnly accepts HTTP/2
Does not do anything if used with
serve_connection_with_upgradesfn http1_only(self) -> SelfOnly accepts HTTP/1
Does not do anything if used with
serve_connection_with_upgradesfn is_http1_available(&self) -> boolReturns
trueif this builder can serve an HTTP/1.1-based connection.fn is_http2_available(&self) -> boolReturns
trueif this builder can serve an HTTP/2-based connection.fn title_case_headers(self, enabled: bool) -> SelfSet whether HTTP/1 connections will write header names as title case at the socket level.
This setting only affects HTTP/1 connections. HTTP/2 connections are not affected by this setting.
Default is false.
Example
use ; new .title_case_headers;fn preserve_header_case(self, enabled: bool) -> SelfSet whether HTTP/1 connections will preserve the original case of header names.
This setting only affects HTTP/1 connections. HTTP/2 connections are not affected by this setting.
Default is false.
Example
use ; new .preserve_header_case;fn serve_connection<I, S, B>(&self, io: I, service: S) -> Connection<'_, I, S, E> where S: Service<Request<Incoming>, Response = Response<B>>, S::Future: 'static, S::Error: Into<Box<dyn StdError + Send + Sync>>, B: Body + 'static, B::Error: Into<Box<dyn StdError + Send + Sync>>, I: Read + Write + Unpin + 'static, E: HttpServerConnExec<S::Future, B>,Bind a connection together with a
Service.fn serve_connection_with_upgrades<I, S, B>(&self, io: I, service: S) -> UpgradeableConnection<'_, I, S, E> where S: Service<Request<Incoming>, Response = Response<B>>, S::Future: 'static, S::Error: Into<Box<dyn StdError + Send + Sync>>, B: Body + 'static, B::Error: Into<Box<dyn StdError + Send + Sync>>, I: Read + Write + Unpin + Send + 'static, E: HttpServerConnExec<S::Future, B>,Bind a connection together with a
Service, with the ability to handle HTTP upgrades. This requires that the IO object implementsSend.Note that if you ever want to use
hyper::upgrade::Upgraded::downcastwith this crate, you'll need to usehyper_util::server::conn::auto::upgrade::downcastinstead. See the documentation of the latter to understand why.
Trait Implementations
impl<E: Clone> Clone for Builder<E>
fn clone(&self) -> Builder<E>
impl<E: Debug> Debug for Builder<E>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<E: Default> Default for Builder<E>
fn default() -> Self
Auto Trait Implementations
impl<E> !RefUnwindSafe for Builder<E>
impl<E> !UnwindSafe for Builder<E>
impl<E> Freeze for Builder<E>
where
Builder<E>: Freeze,
impl<E> Send for Builder<E>
where
Builder<E>: Send,
impl<E> Sync for Builder<E>
where
Builder<E>: Sync,
impl<E> Unpin for Builder<E>
where
Builder<E>: Unpin,
impl<E> UnsafeUnpin for Builder<E>
where
Builder<E>: UnsafeUnpin,
Blanket Implementations
impl<T> Any for Builder<E>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Builder<E>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Builder<E>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Builder<E>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Builder<E>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for Builder<E>
impl<T> ToOwned for Builder<E>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> WithSubscriber for Builder<E>
impl<T, U> Into<U> for Builder<E>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Builder<E>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Builder<E>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>