Skip to main content

ServiceConfig

Struct ServiceConfig 

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

Source

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.

Source

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.

Source

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,

Source§

fn clone(&self) -> ServiceConfig<Cfg>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Cfg> Debug for ServiceConfig<Cfg>
where Cfg: Debug + ServerAppConfig,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Cfg> !RefUnwindSafe for ServiceConfig<Cfg>

§

impl<Cfg> !Send for ServiceConfig<Cfg>

§

impl<Cfg> !Sync for ServiceConfig<Cfg>

§

impl<Cfg> !UnwindSafe for ServiceConfig<Cfg>

§

impl<Cfg> Freeze for ServiceConfig<Cfg>

§

impl<Cfg> Unpin for ServiceConfig<Cfg>

§

impl<Cfg> UnsafeUnpin for ServiceConfig<Cfg>

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.