diff --git a/mediarepo-daemon/mediarepo-socket/src/lib.rs b/mediarepo-daemon/mediarepo-socket/src/lib.rs index ad9665f..0afaeee 100644 --- a/mediarepo-daemon/mediarepo-socket/src/lib.rs +++ b/mediarepo-daemon/mediarepo-socket/src/lib.rs @@ -1,8 +1,24 @@ -use rmp_ipc::IPCBuilder; +use crate::types::responses::InfoResponse; +use rmp_ipc::context::Context; +use rmp_ipc::error::Result; +use rmp_ipc::{Event, IPCBuilder}; mod namespaces; pub mod types; pub fn get_builder(address: &str) -> IPCBuilder { namespaces::build_namespaces(IPCBuilder::new().address(address)) + .on("info", |c, e| Box::pin(info(c, e))) +} + +async fn info(ctx: &Context, event: Event) -> Result<()> { + let response = InfoResponse { + name: env!("CARGO_PKG_NAME").to_string(), + version: env!("CARGO_PKG_VERSION").to_string(), + }; + ctx.emitter + .emit_response(event.id(), "info", response) + .await?; + + Ok(()) } diff --git a/mediarepo-daemon/mediarepo-socket/src/types/responses.rs b/mediarepo-daemon/mediarepo-socket/src/types/responses.rs index 285fdd9..fe1c38d 100644 --- a/mediarepo-daemon/mediarepo-socket/src/types/responses.rs +++ b/mediarepo-daemon/mediarepo-socket/src/types/responses.rs @@ -27,3 +27,9 @@ impl From for FileResponse { } } } + +#[derive(Clone, Debug, Serialize)] +pub struct InfoResponse { + pub name: String, + pub version: String, +}