send_command_with_autospawn

Function send_command_with_autospawn 

Source
pub async fn send_command_with_autospawn<Cmd, Resp>(
    config: &DaemonClientConfig,
    command: &Cmd,
) -> Result<Resp, PluginError>
where Cmd: Serialize, Resp: for<'de> Deserialize<'de>,
Expand description

Send a command to the daemon with automatic spawning if not running

This implements the retry-with-autospawn pattern:

  1. Try to connect to the daemon
  2. If connection fails, spawn the daemon
  3. Wait for startup, then retry connection
  4. Send command and receive response

§Type Parameters

  • Cmd - The command type (must be serializable)
  • Resp - The response type (must be deserializable)

§Arguments

  • config - Configuration for the daemon client
  • command - The command to send

§Returns

The response from the daemon, or an error if communication fails