Struct HttpServerBuilder

Source
pub struct HttpServerBuilder<F, S: State = Empty> { /* private fields */ }
Expand description

Use builder syntax to set the inputs and finish with build().

Implementations§

Source§

impl<F, S: State> HttpServerBuilder<F, S>

Source

pub fn build(self) -> HttpServer<F>
where S: IsComplete,

Finish building and return the requested object

Source

pub fn ctx(self, value: Context) -> HttpServerBuilder<F, SetCtx<S>>
where S::Ctx: IsUnset,

Optional (Some / Option setters). Default: scuffle_context::Context::global().

The [scuffle_context::Context] this server will live by.

Source

pub fn maybe_ctx( self, value: Option<Context>, ) -> HttpServerBuilder<F, SetCtx<S>>
where S::Ctx: IsUnset,

Optional (Some / Option setters). Default: scuffle_context::Context::global().

The [scuffle_context::Context] this server will live by.

Source

pub fn worker_tasks( self, value: usize, ) -> HttpServerBuilder<F, SetWorkerTasks<S>>
where S::WorkerTasks: IsUnset,

Optional (Some / Option setters). Default: 1.

The number of worker tasks to spawn for each server backend.

Source

pub fn maybe_worker_tasks( self, value: Option<usize>, ) -> HttpServerBuilder<F, SetWorkerTasks<S>>
where S::WorkerTasks: IsUnset,

Optional (Some / Option setters). Default: 1.

The number of worker tasks to spawn for each server backend.

Source

pub fn service_factory( self, value: F, ) -> HttpServerBuilder<F, SetServiceFactory<S>>
where S::ServiceFactory: IsUnset,

Required.

The service factory that will be used to create new services.

Source

pub fn bind(self, value: SocketAddr) -> HttpServerBuilder<F, SetBind<S>>
where S::Bind: IsUnset,

Required.

The address to bind to.

Use [::] for a dual-stack listener. For example, use [::]:80 to bind to port 80 on both IPv4 and IPv6.

Source

pub fn enable_http1( self, value: bool, ) -> HttpServerBuilder<F, SetEnableHttp1<S>>
where S::EnableHttp1: IsUnset,

Optional (Some / Option setters). Default: true.

Enable HTTP/1.1.

Source

pub fn maybe_enable_http1( self, value: Option<bool>, ) -> HttpServerBuilder<F, SetEnableHttp1<S>>
where S::EnableHttp1: IsUnset,

Optional (Some / Option setters). Default: true.

Enable HTTP/1.1.

Source

pub fn enable_http2( self, value: bool, ) -> HttpServerBuilder<F, SetEnableHttp2<S>>
where S::EnableHttp2: IsUnset,

Optional (Some / Option setters). Default: true.

Enable HTTP/2.

Source

pub fn maybe_enable_http2( self, value: Option<bool>, ) -> HttpServerBuilder<F, SetEnableHttp2<S>>
where S::EnableHttp2: IsUnset,

Optional (Some / Option setters). Default: true.

Enable HTTP/2.

Source

pub fn rustls_config( self, value: ServerConfig, ) -> HttpServerBuilder<F, SetRustlsConfig<S>>
where S::RustlsConfig: IsUnset,

Optional (Some / Option setters).

rustls config.

Use this field to set the server into TLS mode. It will only accept TLS connections when this is set.

Source

pub fn maybe_rustls_config( self, value: Option<ServerConfig>, ) -> HttpServerBuilder<F, SetRustlsConfig<S>>
where S::RustlsConfig: IsUnset,

Optional (Some / Option setters).

rustls config.

Use this field to set the server into TLS mode. It will only accept TLS connections when this is set.

Source§

impl<F, S> HttpServerBuilder<F, S>
where S: State, S::EnableHttp3: IsUnset, S::RustlsConfig: IsSet,

Source

pub fn enable_http3( self, enable_http3: bool, ) -> HttpServerBuilder<F, SetEnableHttp3<S>>

Available on crate feature http3 only.

Enable HTTP/3 support.

First enable TLS by calling rustls_config to enable HTTP/3.

Source§

impl<M, S> HttpServerBuilder<TowerMakeServiceFactory<M, ()>, S>
where M: MakeService<(), IncomingRequest> + Send, M::Future: Send, M::Service: HttpService, S: State, S::ServiceFactory: IsUnset,

Source

pub fn tower_make_service_factory( self, tower_make_service: M, ) -> HttpServerBuilder<TowerMakeServiceFactory<M, ()>, SetServiceFactory<S>>

Available on crate feature tower only.

Same as calling service_factory(tower_make_service_factory(tower_make_service)).

§See Also
Source§

impl<M, S> HttpServerBuilder<TowerMakeServiceWithAddrFactory<M>, S>
where M: MakeService<SocketAddr, IncomingRequest> + Send, M::Future: Send, M::Service: HttpService, S: State, S::ServiceFactory: IsUnset,

Source

pub fn tower_make_service_with_addr( self, tower_make_service: M, ) -> HttpServerBuilder<TowerMakeServiceWithAddrFactory<M>, SetServiceFactory<S>>

Available on crate feature tower only.

Same as calling service_factory(tower_make_service_with_addr_factory(tower_make_service)).

§See Also
Source§

impl<M, T, S> HttpServerBuilder<TowerMakeServiceFactory<M, T>, S>
where M: MakeService<T, IncomingRequest> + Send, M::Future: Send, M::Service: HttpService, T: Clone + Send, S: State, S::ServiceFactory: IsUnset,

Source

pub fn custom_tower_make_service_factory( self, tower_make_service: M, target: T, ) -> HttpServerBuilder<TowerMakeServiceFactory<M, T>, SetServiceFactory<S>>

Available on crate feature tower only.

Same as calling service_factory(custom_tower_make_service_factory(tower_make_service, target)).

§See Also

Auto Trait Implementations§

§

impl<F, S> Freeze for HttpServerBuilder<F, S>
where F: Freeze,

§

impl<F, S = Empty> !RefUnwindSafe for HttpServerBuilder<F, S>

§

impl<F, S> Send for HttpServerBuilder<F, S>
where F: Send,

§

impl<F, S> Sync for HttpServerBuilder<F, S>
where F: Sync,

§

impl<F, S> Unpin for HttpServerBuilder<F, S>
where F: Unpin,

§

impl<F, S = Empty> !UnwindSafe for HttpServerBuilder<F, S>

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.

§

impl<T> Instrument for T

§

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

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

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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