p9cpu: rename CommandReq to Cmd

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
This commit is contained in:
Changyuan Lyu 2023-05-26 16:03:06 -07:00
parent b0289c9b4e
commit 898c667c46
6 changed files with 17 additions and 17 deletions

View file

@ -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<Output = Result<(), Self::Error>> + 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);

View file

@ -15,7 +15,7 @@ message EnvVar {
bytes val = 2;
}
message CommandReq {
message Cmd {
string program = 1;
repeated string args = 2;
repeated EnvVar envs = 3;

View file

@ -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<Item = String>) -> &mut Self {
self.req.args.extend(args);
self.cmd.args.extend(args);
self
}
@ -67,7 +67,7 @@ impl Command {
K: Into<Vec<u8>>,
V: Into<Vec<u8>>,
{
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<Item = FsTab>) -> &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
}
}

View file

@ -5,7 +5,7 @@ import "cmd.proto";
message StartRequest {
bytes id = 1;
cmd.CommandReq cmd = 2;
cmd.Cmd cmd = 2;
}
message StdinRequest {

View file

@ -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(),

View file

@ -26,7 +26,7 @@ impl<I> Default for Server<I> {
}
impl<I> Server<I> {
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!()
}