Skip to main content

Server

Struct Server 

Source
pub struct Server<T> { /* private fields */ }
Expand description

Controller and completion future for a running server.

Clones can pause, resume, stop, or submit items to the server. Awaiting a Server resolves when the server has stopped. It always resolves to Ok(()).

Implementations§

Source§

impl Server<Connection>

Source

pub fn builder() -> ServerBuilder

Creates a network server builder with no application configuration.

Source§

impl<T> Server<T>

Source

pub fn process(&self, item: T) -> Result<(), T>

Submits an item to the worker pool.

Returns the item unchanged if the server is paused or cannot accept it.

The server starts paused and resumes once the first worker is ready. It also pauses itself while no worker is available, so items submitted right after start or during worker restarts may be rejected.

Source

pub fn pause(&self) -> impl Future<Output = ()> + use<T>

Pauses processing new items.

For network servers, listeners stop accepting connections, so new connections wait in the kernel listen backlog. Existing connections remain active.

Source

pub fn resume(&self) -> impl Future<Output = ()> + use<T>

Resumes processing new items.

Source

pub fn stop(&self, graceful: bool) -> impl Future<Output = ()> + use<T>

Stops processing new items and shuts down all workers.

If graceful is true, workers are given up to the graceful shutdown timeout to finish active work before they are stopped. A zero timeout makes the stop non-graceful.

The returned future resolves once the stop has completed. If the server has already stopped, it resolves immediately.

Trait Implementations§

Source§

impl<T> Clone for Server<T>

Source§

fn clone(&self) -> Self

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<T: Debug> Debug for Server<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Future for Server<T>

Source§

type Output = Result<(), Error>

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Server<T>

§

impl<T> !Sync for Server<T>

§

impl<T> !UnwindSafe for Server<T>

§

impl<T> Freeze for Server<T>

§

impl<T> Send for Server<T>
where T: Send,

§

impl<T> Unpin for Server<T>

§

impl<T> UnsafeUnpin for Server<T>

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<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
Source§

impl<F> OnDropFutureExt for F
where F: Future,

Source§

fn on_drop<F>(self, on_drop: F) -> OnDropFuture<Self, F> ⓘ
where F: FnOnce(),

Wraps this future so that on_drop is called if the future is dropped before it completes. The callback is cancelled once the future completes, whatever its output.
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.
§

impl<F, T, E> TryFuture for F
where F: Future<Output = Result<T, E>> + ?Sized,

§

type Ok = T

The type of successful values yielded by this future
§

type Error = E

The type of failures yielded by this future
§

fn try_poll( self: Pin<&mut F>, cx: &mut Context<'_>, ) -> Poll<<F as Future>::Output>

Poll this TryFuture as if it were a Future. Read more
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.