git.delta.rocks / remowt / refs/commits / a70745c0fb24

difftreelog

feat remote editor

oxowswprYaroslav Bolyukin2026-01-25parent: #67b2134.patch.diff
in: trunk

2 files changed

modifiedcrates/remowt-link-shared/Cargo.tomldiffbeforeafterboth
55
6[dependencies]6[dependencies]
7bifrostlink.workspace = true7bifrostlink.workspace = true
8bytes.workspace = true
8serde = { version = "1.0.208", features = ["derive"] }9serde = { workspace = true, features = ["derive"] }
9serde_json = "1.0.125"10serde_json.workspace = true
10thiserror = "1.0.63"11thiserror = "1.0.63"
11tokio = "1.39.3"12tokio = { workspace = true, features = ["fs"] }
13remowt-fs.workspace = true
14remowt-systemd.workspace = true
15ui-prompt.workspace = true
16camino = { workspace = true, features = ["serde1"] }
17remowt-pty.workspace = true
1218
addedcrates/remowt-link-shared/src/editor.rsdiffbeforeafterboth
--- /dev/null
+++ b/crates/remowt-link-shared/src/editor.rs
@@ -0,0 +1,33 @@
+use std::future::Future;
+
+use bifrostlink::declarative::endpoints;
+use bifrostlink::{Config, Rpc};
+use serde::{Deserialize, Serialize};
+
+#[derive(Serialize, Deserialize, Debug, thiserror::Error)]
+pub enum Error {
+	#[error("editor failed: {0}")]
+	Failed(String),
+}
+
+pub trait EditorBackend: Send + Sync {
+	fn open_editor(&self, socket_path: String) -> impl Future<Output = Result<(), Error>> + Send;
+}
+
+pub struct EditorEndpoints<E>(pub E);
+
+#[endpoints(ns = 8)]
+impl<E: EditorBackend + 'static> EditorEndpoints<E> {
+	#[endpoints(id = 1)]
+	async fn open_editor(&self, socket_path: String) -> Result<(), Error> {
+		self.0.open_editor(socket_path).await
+	}
+}
+
+pub fn serve_editor<E, C>(rpc: &mut Rpc<C>, editor: E)
+where
+	E: EditorBackend + Send + Sync + 'static,
+	C: Config,
+{
+	EditorEndpoints(editor).register_endpoints(rpc);
+}