Skip to content

Commit 421f440

Browse files
authored
Merge pull request #2 from nikomatsakis/refactor/remove-acp-dependency
remove dependency on ACP
2 parents bf32d95 + 62ee268 commit 421f440

39 files changed

+1066
-1257
lines changed

Cargo.lock

Lines changed: 5 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tokio = { version = "1.0", features = ["full"] }
1212
tokio-util = { version = "0.7", features = ["compat"] }
1313

1414
# Protocol
15-
agent-client-protocol = "0.7"
15+
agent-client-protocol-schema = "0.6.3"
1616

1717
# Serialization
1818
serde = { version = "1.0", features = ["derive"] }

src/sacp-conductor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test-support = []
1414
[dependencies]
1515
sacp = { version = "0.1.0", path = "../sacp" }
1616
sacp-proxy = { version = "0.1.0", path = "../sacp-proxy" }
17-
agent-client-protocol.workspace = true
17+
agent-client-protocol-schema.workspace = true
1818
anyhow.workspace = true
1919
clap.workspace = true
2020
futures.workspace = true

src/sacp-conductor/src/component.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use agent_client_protocol as acp;
1+
use sacp;
22
use std::pin::Pin;
33
use tokio_util::compat::{FuturesAsyncReadCompatExt as _, FuturesAsyncWriteCompatExt};
44

55
use futures::{AsyncRead, AsyncWrite};
66

7-
use sacp::JsonRpcConnectionCx;
7+
use sacp::JrConnectionCx;
88
use tokio::process::Child;
99
use tracing::debug;
1010

@@ -21,10 +21,10 @@ pub trait ComponentProvider: Send {
2121
/// * `incoming_bytes`: bytes received by the conponent from the conductor.
2222
fn create(
2323
&self,
24-
cx: &JsonRpcConnectionCx,
24+
cx: &JrConnectionCx,
2525
outgoing_bytes: Pin<Box<dyn AsyncWrite + Send>>,
2626
incoming_bytes: Pin<Box<dyn AsyncRead + Send>>,
27-
) -> Result<Cleanup, acp::Error>;
27+
) -> Result<Cleanup, sacp::Error>;
2828
}
2929

3030
/// Cleanup enum returned by component provider.
@@ -60,7 +60,7 @@ pub struct Component {
6060

6161
/// The connection context to the component. This is called `agent_cx` because the
6262
/// component is acting as the conductor's agent.
63-
pub agent_cx: JsonRpcConnectionCx,
63+
pub agent_cx: JrConnectionCx,
6464
}
6565

6666
/// A "command provider" provides a component by running a command and sending ACP messages to/from stdio.
@@ -77,17 +77,17 @@ impl CommandComponentProvider {
7777
impl ComponentProvider for CommandComponentProvider {
7878
fn create(
7979
&self,
80-
cx: &JsonRpcConnectionCx,
80+
cx: &JrConnectionCx,
8181
outgoing_bytes: Pin<Box<dyn AsyncWrite + Send>>,
8282
incoming_bytes: Pin<Box<dyn AsyncRead + Send>>,
83-
) -> Result<Cleanup, acp::Error> {
83+
) -> Result<Cleanup, sacp::Error> {
8484
debug!(command = self.command, "Spawning command");
8585

8686
let mut child = tokio::process::Command::new(&self.command)
8787
.stdin(std::process::Stdio::piped())
8888
.stdout(std::process::Stdio::piped())
8989
.spawn()
90-
.map_err(acp::Error::into_internal_error)?;
90+
.map_err(sacp::Error::into_internal_error)?;
9191

9292
// Take ownership of the streams (can only do this once!)
9393
let mut child_stdin = child.stdin.take().expect("Failed to open stdin");
@@ -96,14 +96,14 @@ impl ComponentProvider for CommandComponentProvider {
9696
cx.spawn(async move {
9797
tokio::io::copy(&mut incoming_bytes.compat(), &mut child_stdin)
9898
.await
99-
.map_err(acp::Error::into_internal_error)?;
99+
.map_err(sacp::Error::into_internal_error)?;
100100
Ok(())
101101
})?;
102102

103103
cx.spawn(async move {
104104
tokio::io::copy(&mut child_stdout, &mut outgoing_bytes.compat_write())
105105
.await
106-
.map_err(acp::Error::into_internal_error)?;
106+
.map_err(sacp::Error::into_internal_error)?;
107107
Ok(())
108108
})?;
109109

0 commit comments

Comments
 (0)