INNER CODE UNIT · Rust
request
xuzhougeng/wisp-science · crates/wisp-acp/src/lib.rs:409
async fn request<T>(&self, command: impl FnOnce(Reply<T>) -> Command) -> Result<T, AcpError> {
let (reply_tx, reply_rx) = oneshot::channel();
self.command_tx
.send(command(reply_tx))
.map_err(|_| AcpError::Closed)?;
reply_rx.await.map_err(|_| AcpError::Closed)?
}
}
async fn launch_transport(
process: impl ConnectTo<Client>,
stderr: BoundedStderr,
) -> Result<AcpSessionHandle, AcpError> {
let (command_tx, command_rx) = mpsc::unbounded_channel();
let (event_tx, event_rx) = mpsc::unbounded_channel();
let (ready_tx, ready_rx) = oneshot::channel();
let mut actor = LaunchActor(Some(tokio::spawn(async move {
let result = run_actor(process, command_rx, event_tx.clone(), ready_tx).await;