struct AppState {
command: Mutext<Option<Child>>
}
fn start_command(state: State<'_, AppState) {
let command = Command::new('binary path').args(args).spawn();
*state.command.lock().unwrap() = Some(command);
}
fn stop_command(state: State<'_, AppState) {
state
.command
.lock()
.unwrap()
.as_ref()
.expect("child")
.stdin
.as_ref()
.unwrap()
.write("q".as_bytes());
}
Need to store a command child in state so that I can write to it later to tell the command to stop. I feel like this is a close as I've gotten to a correct solution but with the code like this the command starts correctly but when trying to stop it stdin is returning an Option<none> and then failing when I try to unwrap it and I really am at a loss as to why