Skip to main content

Server

Struct Server 

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

A running server. Dropping it stops it (with a drain), so keep it and call Server::wait_for_stop to run until a stop is requested.

Implementations§

Source§

impl Server

Source

pub fn open_door(&self) -> Result<(), NetError>

Starts accepting on every listener; a second call is a no-op.

§Errors

ShuttingDown while draining or after shutdown; ForkedChild.

Source

pub fn close_door(&self)

Stops accepting within one loop iteration; listening sockets stay open. Idempotent.

Source

pub fn door(&self) -> DoorState

Whether the server is accepting.

Source

pub fn drain(&self, deadline: Instant) -> DrainReport

Closes the door, tells sessions to finish, closes idle connections at once, waits for the rest until deadline, then kills them with DrainDeadline.

Source

pub fn shutdown(self, deadline: Instant) -> DrainReport

Drains, then closes the listening sockets and joins every thread.

Source

pub fn wait_for_stop(self) -> DrainReport

Blocks until a stop is requested (ServerHandle::request_stop, or the control line moves to Draining or Stopping), then shuts down.

Source

pub fn handle(&self) -> ServerHandle

A cloneable handle for other threads.

Source

pub fn stats(&self) -> Stats

Counters summed over the workers.

Source

pub fn listeners(&self) -> &[ListenerInfo]

Facts about each listener.

Trait Implementations§

Source§

impl Debug for Server

Source§

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

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

impl Drop for Server

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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.

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.