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
before · crates/remowt-link-shared/Cargo.toml
1[package]2name = "remowt-link-shared"3version = "0.1.0"4edition = "2021"56[dependencies]7bifrostlink.workspace = true8serde = { version = "1.0.208", features = ["derive"] }9serde_json = "1.0.125"10thiserror = "1.0.63"11tokio = "1.39.3"
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);
+}