aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/plugin_api/command.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-08-09 22:26:00 +0200
committerGitHub <noreply@github.com>2023-08-09 22:26:00 +0200
commit1bedfc90021558cb201695444107afe5bddd2c17 (patch)
tree38dd31b5ab112aa9b1c3a54edb07331013bf7d87 /zellij-utils/src/plugin_api/command.rs
parentdocs(changelog): plug memory leak (diff)
downloadsl0ppij-1bedfc90021558cb201695444107afe5bddd2c17.tar.gz
sl0ppij-1bedfc90021558cb201695444107afe5bddd2c17.tar.xz
sl0ppij-1bedfc90021558cb201695444107afe5bddd2c17.zip
feat(plugins): use protocol buffers for serializing across the wasm boundary (#2686)
* work * almost done with command protobuffers * done translating command data structures * mid transferring of every command to protobuff command * transferred plugin_command.rs, now moving on to shim.rs * plugin command working with protobufs * protobuffers in update * protobuf event tests * various TODOs and comments * fix zellij-tile * clean up prost deps * remove version mismatch error * fix panic * some cleanups * clean up event protobuffers * clean up command protobuffers * clean up various protobufs * refactor protobufs * update comments * some transformation fixes * use protobufs for workers * style(fmt): rustfmt * style(fmt): rustfmt * chore(build): add protoc * chore(build): authenticate protoc
Diffstat (limited to 'zellij-utils/src/plugin_api/command.rs')
-rw-r--r--zellij-utils/src/plugin_api/command.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/zellij-utils/src/plugin_api/command.rs b/zellij-utils/src/plugin_api/command.rs
new file mode 100644
index 00000000..2f8bf300
--- /dev/null
+++ b/zellij-utils/src/plugin_api/command.rs
@@ -0,0 +1,26 @@
+pub use super::generated_api::api::command::Command as ProtobufCommand;
+use crate::data::CommandToRun;
+
+use std::convert::TryFrom;
+use std::path::PathBuf;
+
+impl TryFrom<ProtobufCommand> for CommandToRun {
+ type Error = &'static str;
+ fn try_from(protobuf_command: ProtobufCommand) -> Result<Self, &'static str> {
+ let path = PathBuf::from(protobuf_command.path);
+ let args = protobuf_command.args;
+ let cwd = protobuf_command.cwd.map(|c| PathBuf::from(c));
+ Ok(CommandToRun { path, args, cwd })
+ }
+}
+
+impl TryFrom<CommandToRun> for ProtobufCommand {
+ type Error = &'static str;
+ fn try_from(command_to_run: CommandToRun) -> Result<Self, &'static str> {
+ Ok(ProtobufCommand {
+ path: command_to_run.path.display().to_string(),
+ args: command_to_run.args,
+ cwd: command_to_run.cwd.map(|c| c.display().to_string()),
+ })
+ }
+}