mod keys;
mod protocol;
pub use protocol::{Dispatcher, RpcError, METHODS, PROTOCOL_VERSION};
pub use uzor_devtools as devtools;
use std::sync::Arc;
use crate::automation::AutomationClient;
pub struct DevControl {
endpoint: uzor_devtools::Endpoint,
dispatcher: Arc<Dispatcher>,
}
impl DevControl {
pub fn port(&self) -> u16 {
self.endpoint.port()
}
pub fn discovery_path(&self) -> &std::path::Path {
self.endpoint.discovery_path()
}
pub fn dispatcher(&self) -> &Arc<Dispatcher> {
&self.dispatcher
}
}
pub fn start(app_dir: &str, app: &str, client: AutomationClient) -> std::io::Result<DevControl> {
let dispatcher = Arc::new(Dispatcher::new(app, client));
let endpoint = uzor_devtools::serve(app_dir, app, Arc::clone(&dispatcher) as Arc<dyn uzor_devtools::Rpc>)?;
Ok(DevControl { endpoint, dispatcher })
}