(&self, cmd: IpcCommand)
| 45 | } |
| 46 | |
| 47 | fn send_command(&self, cmd: IpcCommand) -> Result<IpcResponse> { |
| 48 | let (response_tx, response_rx) = ipc::channel::<IpcResponse>()?; |
| 49 | |
| 50 | let msg = IpcMessage { |
| 51 | command: cmd, |
| 52 | response_channel: response_tx, |
| 53 | }; |
| 54 | |
| 55 | self.sender.send(msg).context("Failed to send command")?; |
| 56 | let response = response_rx.recv().context("Failed to receive response")?; |
| 57 | |
| 58 | Ok(response) |
| 59 | } |
| 60 | |
| 61 | pub fn enable(&self) -> Result<()> { |
| 62 | let response = self.send_command(IpcCommand::Enable)?; |