Connects a new SDL console client to an already-configured host.
(
request_tx: SyncSender<Request>,
response_rx: Receiver<Response>,
on_key_rx: Receiver<Key>,
)
| 41 | impl SdlConsole { |
| 42 | /// Connects a new SDL console client to an already-configured host. |
| 43 | pub(crate) fn new( |
| 44 | request_tx: SyncSender<Request>, |
| 45 | response_rx: Receiver<Response>, |
| 46 | on_key_rx: Receiver<Key>, |
| 47 | ) -> io::Result<Self> { |
| 48 | // Wait for the host to be up and running. We must do this for error propagation. |
| 49 | match response_rx.recv().expect("Channel must be alive") { |
| 50 | Response::Empty(Ok(())) => Ok(Self { |
| 51 | request_tx, |
| 52 | response_rx, |
| 53 | on_key_rx, |
| 54 | fg_color: None, |
| 55 | bg_color: None, |
| 56 | alt_backup: None, |
| 57 | }), |
| 58 | Response::Empty(Err(e)) => Err(e), |
| 59 | r => panic!("Unexpected response {:?}", r), |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /// Issues a synchronous call against the console host for a request that returns nothing but |
| 64 | /// an error (if any). |
nothing calls this directly
no test coverage detected