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§
Sourcefn discover(&self) -> Result<Option<HostGeneration>>
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.
Sourcefn connect(
&self,
host: &HostGeneration,
) -> Result<Box<dyn HostLink>, LifecycleError>
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.
Sourcefn claim_spawn(&self) -> Result<SpawnPermit>
fn claim_spawn(&self) -> Result<SpawnPermit>
Take the cross-process claim that serialises starting a host.
Provided Methods§
Sourcefn is_current(&self, host: &HostGeneration) -> Result<bool>
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".