Skip to main content

HostBackend

Trait HostBackend 

Source
pub trait HostBackend:
    Send
    + Sync
    + 'static {
    // Required methods
    fn discover(&self) -> Result<Option<HostGeneration>>;
    fn connect(
        &self,
        host: &HostGeneration,
    ) -> Result<Box<dyn HostLink>, LifecycleError>;
    fn claim_spawn(&self) -> Result<SpawnPermit>;

    // Provided method
    fn is_current(&self, host: &HostGeneration) -> Result<bool> { ... }
}
Expand description

How a lifecycle finds, verifies and reaches a host. LocalBackend is the service.json transport; tests and other transports implement it too.

Required Methods§

Source

fn discover(&self) -> Result<Option<HostGeneration>>

The live published host now, or None. An unreadable record is Err (unknown), never None: the lifecycle must not start a second host on an unknown.

Source

fn connect( &self, host: &HostGeneration, ) -> Result<Box<dyn HostLink>, LifecycleError>

Open a connection to exactly host, after verifying who is on the other end. A host that fails the identity check is LifecycleError::HostIdentity; nothing application-level was sent to it.

Source

fn claim_spawn(&self) -> Result<SpawnPermit>

Take the cross-process claim that serialises starting a host.

Provided Methods§

Source

fn is_current(&self, host: &HostGeneration) -> Result<bool>

Whether host is still the published, live generation. Called before every request and before every reply is handed back, so it should be cheap (no connection).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§