pub struct ServiceConfig<Cfg>(/* private fields */)
where
Cfg: ServerAppConfig;Expand description
Listener and worker configuration used by ServerBuilder::configure.
Listeners are registered by name. Each worker then runs the
on_worker_start callbacks, which attach a
service to each name through ServiceRuntime::service.
Implementations§
Source§impl<Cfg> ServiceConfig<Cfg>where
Cfg: ServerAppConfig,
impl<Cfg> ServiceConfig<Cfg>where
Cfg: ServerAppConfig,
Sourcepub fn bind(
&self,
name: impl AsRef<str>,
addr: impl ToSocketAddrs,
) -> Result<&ServiceConfig<Cfg>, Error>
pub fn bind( &self, name: impl AsRef<str>, addr: impl ToSocketAddrs, ) -> Result<&ServiceConfig<Cfg>, Error>
Binds TCP listeners under the specified name.
A listener is created for every address resolved from addr, using
the builder’s backlog. Binding succeeds if at least one address binds.
The service for name is attached later with
ServiceRuntime::service.
Sourcepub fn listen(
&self,
name: impl AsRef<str>,
lst: TcpListener,
) -> &ServiceConfig<Cfg>
pub fn listen( &self, name: impl AsRef<str>, lst: TcpListener, ) -> &ServiceConfig<Cfg>
Registers an existing TCP listener under the specified name.
The listener is switched to non-blocking mode. The service for name
is attached later with ServiceRuntime::service.
Sourcepub fn on_worker_start<F>(&self, f: F) -> &ServiceConfig<Cfg>where
F: AsyncFnOnce(ServiceRuntime<<Cfg as ServerAppConfig>::State>) -> Result<(), Error> + Send + Clone + 'static,
pub fn on_worker_start<F>(&self, f: F) -> &ServiceConfig<Cfg>where
F: AsyncFnOnce(ServiceRuntime<<Cfg as ServerAppConfig>::State>) -> Result<(), Error> + Send + Clone + 'static,
Registers an asynchronous worker configuration callback.
The callback runs on each worker thread while the worker creates its services, and it should attach a service to every registered name. Multiple callbacks run in registration order. An error fails the worker’s service creation. Names left without a service are logged as errors, and their connections are dropped.
Trait Implementations§
Source§impl<Cfg> Clone for ServiceConfig<Cfg>where
Cfg: ServerAppConfig,
impl<Cfg> Clone for ServiceConfig<Cfg>where
Cfg: ServerAppConfig,
Source§fn clone(&self) -> ServiceConfig<Cfg>
fn clone(&self) -> ServiceConfig<Cfg>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more