pub trait MockProtocolServer: Send + Sync {
// Required methods
fn protocol(&self) -> Protocol;
fn start<'life0, 'async_trait>(
&'life0 self,
shutdown: Receiver<()>,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn port(&self) -> u16;
fn description(&self) -> String;
}Expand description
Trait for mock protocol server lifecycle management.
Each protocol crate implements this to provide a uniform startup interface.
The CLI can collect Box<dyn MockProtocolServer> instances and launch them
all through a single code path, rather than having bespoke startup logic
for each protocol.
Implementations should:
Required Methods§
Sourcefn start<'life0, 'async_trait>(
&'life0 self,
shutdown: Receiver<()>,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
shutdown: Receiver<()>,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start the server, running until the shutdown signal is received.
The server should listen on its configured address and handle requests
until the shutdown receiver signals (i.e., the sender is dropped or
a value is sent). Implementations should use tokio::select! to
combine the server’s accept loop with the shutdown signal.
§Errors
Returns an error if the server fails to bind, encounters a fatal I/O error, or any other unrecoverable condition.
Sourcefn description(&self) -> String
fn description(&self) -> String
Human-readable description for logging (e.g., “gRPC server on port 50051”).