diff --git a/crates/libp9cpu/src/client.rs b/crates/libp9cpu/src/client.rs index e7e8051..558f87e 100644 --- a/crates/libp9cpu/src/client.rs +++ b/crates/libp9cpu/src/client.rs @@ -1,5 +1,5 @@ use crate::cmd; -use crate::cmd::CommandReq; +use crate::cmd::Cmd; use crate::rpc; use async_trait::async_trait; use futures::{Future, Stream, StreamExt}; @@ -32,7 +32,7 @@ pub trait ClientInnerT { /// Starts the command on the remote machine. This method should return as /// long as the command is spawned successfully. To obtained the command /// return code, call [wait()](Self::wait). - async fn start(&self, sid: Self::SessionId, command: CommandReq) -> Result<(), Self::Error>; + async fn start(&self, sid: Self::SessionId, command: Cmd) -> Result<(), Self::Error>; type EmptyFuture: Future> + Send + 'static; @@ -184,12 +184,12 @@ where if self.session_info.is_some() { return Err(ClientError::AlreadyStarted)?; } - let tty = command.req.tty; + let tty = command.cmd.tty; let sid = self.inner.dial().await?; - if command.req.ninep { + if command.cmd.ninep { unimplemented!("local 9p server is not implemented yet.") } - self.inner.start(sid.clone(), command.req).await?; + self.inner.start(sid.clone(), command.cmd).await?; let (stop_tx, stop_rx) = broadcast::channel(1); diff --git a/crates/libp9cpu/src/cmd.proto b/crates/libp9cpu/src/cmd.proto index c302e38..b53f579 100644 --- a/crates/libp9cpu/src/cmd.proto +++ b/crates/libp9cpu/src/cmd.proto @@ -15,7 +15,7 @@ message EnvVar { bytes val = 2; } -message CommandReq { +message Cmd { string program = 1; repeated string args = 2; repeated EnvVar envs = 3; diff --git a/crates/libp9cpu/src/cmd.rs b/crates/libp9cpu/src/cmd.rs index e09a4d8..98f2881 100644 --- a/crates/libp9cpu/src/cmd.rs +++ b/crates/libp9cpu/src/cmd.rs @@ -43,13 +43,13 @@ impl TryFrom<&str> for FsTab { } pub struct Command { - pub(crate) req: CommandReq, + pub(crate) cmd: Cmd, } impl Command { pub fn new(program: String) -> Self { Self { - req: CommandReq { + cmd: Cmd { program, ..Default::default() }, @@ -57,7 +57,7 @@ impl Command { } pub fn args(&mut self, args: impl IntoIterator) -> &mut Self { - self.req.args.extend(args); + self.cmd.args.extend(args); self } @@ -67,7 +67,7 @@ impl Command { K: Into>, V: Into>, { - self.req.envs.extend(vars.into_iter().map(|(k, v)| EnvVar { + self.cmd.envs.extend(vars.into_iter().map(|(k, v)| EnvVar { key: k.into(), val: v.into(), })); @@ -75,22 +75,22 @@ impl Command { } pub fn fstab(&mut self, tab: impl IntoIterator) -> &mut Self { - self.req.fstab.extend(tab); + self.cmd.fstab.extend(tab); self } pub fn ninep(&mut self, enable: bool) -> &mut Self { - self.req.ninep = enable; + self.cmd.ninep = enable; self } pub fn tty(&mut self, enable: bool) -> &mut Self { - self.req.tty = enable; + self.cmd.tty = enable; self } pub fn tmp_mnt(&mut self, tmp_mnt: String) -> &mut Self { - self.req.tmp_mnt = tmp_mnt; + self.cmd.tmp_mnt = tmp_mnt; self } } diff --git a/crates/libp9cpu/src/rpc/p9cpu.proto b/crates/libp9cpu/src/rpc/p9cpu.proto index c31b539..df78543 100644 --- a/crates/libp9cpu/src/rpc/p9cpu.proto +++ b/crates/libp9cpu/src/rpc/p9cpu.proto @@ -5,7 +5,7 @@ import "cmd.proto"; message StartRequest { bytes id = 1; - cmd.CommandReq cmd = 2; + cmd.Cmd cmd = 2; } message StdinRequest { diff --git a/crates/libp9cpu/src/rpc/rpc_client.rs b/crates/libp9cpu/src/rpc/rpc_client.rs index 64ac01e..57e9b40 100644 --- a/crates/libp9cpu/src/rpc/rpc_client.rs +++ b/crates/libp9cpu/src/rpc/rpc_client.rs @@ -105,7 +105,7 @@ impl crate::client::ClientInnerT for RpcClient { async fn start( &self, sid: Self::SessionId, - command: cmd::CommandReq, + command: cmd::Cmd, ) -> Result<(), Self::Error> { let req = rpc::StartRequest { id: sid.into_bytes().into(), diff --git a/crates/libp9cpu/src/server.rs b/crates/libp9cpu/src/server.rs index 690b346..c2bd1e8 100644 --- a/crates/libp9cpu/src/server.rs +++ b/crates/libp9cpu/src/server.rs @@ -26,7 +26,7 @@ impl Default for Server { } impl Server { - pub async fn start(&self, _command: cmd::CommandReq, _sid: I) -> Result<(), Error> { + pub async fn start(&self, _command: cmd::Cmd, _sid: I) -> Result<(), Error> { unimplemented!() }