Struct Server

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

Server side of the connection, which runs in the monitor process that is meant to monitor the process where the super::Client resides

Implementations§

Source§

impl Server

Source

pub fn with_name<'scope>( name: impl Into<SocketName<'scope>>, ) -> Result<Self, Error>

Creates a new server with the given name.

Note that in the case of a path socket name, this method always attempts to delete the specified path if it exists as both Windows and Macos have issues around cleaning up these files if the process the server runs in aborts abnormally.

§Errors

The provided socket name is invalid, or the listener socket was unable to be bound to the specified socket name.

Source

pub fn run( &mut self, handler: Box<dyn ServerHandler>, shutdown: &AtomicBool, stale_timeout: Option<Duration>, ) -> Result<(), Error>

Runs the server loop, accepting client connections and receiving IPC messages.

If stale_timeout is specified, client connections that have not sent a message within that period will be shutdown and removed, to prevent potential issues with the server process from indefinitely outlasting the process(es) it was monitoring for crashes, in cases where the OS (read, Windows) might take longer than one would want to properly reap the client connections in the event of adrupt process termination. Sending messages will prevent the connection from going stale, but if messages are not guaranteed to be sent at a higher frequency than your specified timeout, you can use crate::Client::ping to fill in any message gaps to indicate the client is still alive.

§Errors

This method uses basic I/O event notification via polling which can fail for a number of different reasons

Trait Implementations§

Source§

impl Drop for Server

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Server

§

impl RefUnwindSafe for Server

§

impl Send for Server

§

impl Sync for Server

§

impl Unpin for Server

§

impl UnwindSafe for Server

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