//! Dev backend: socket-only daemon. No FSKit, no `mount(8)`. //! //! Listens on `127.0.0.1:$SUBTEXT_DEV_PORT` (default `8080`). A client //! (e.g. FSKitBridge or a local test harness) connects and drives the //! [`Filesystem`] over the wire. use async_trait::async_trait; use fskit_rs::dev_session::DevSession; use fskit_rs::{Filesystem, MountOptions}; use super::{Backend, Result}; const DEFAULT_PORT: u16 = 8080; #[derive(Debug)] pub struct DevBackend { port: u16, // Held for its `Drop` impl, which stops the socket. _session: DevSession, } #[async_trait] impl Backend for DevBackend { async fn start(fs: FS, _opts: MountOptions) -> Result where FS: Filesystem + Send + Sync + Clone + 'static, { let port = std::env::var("SUBTEXT_DEV_PORT") .ok() .and_then(|v| v.parse().ok()) .unwrap_or(DEFAULT_PORT); let session = DevSession::new(fs, port).await?; Ok(Self { port, _session: session }) } fn describe(&self) -> String { format!("dev socket on 127.0.0.1:{}", self.port) } }