Add info event

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 01b3a33099
commit 6ffb6c5ebb

@ -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; mod namespaces;
pub mod types; pub mod types;
pub fn get_builder(address: &str) -> IPCBuilder { pub fn get_builder(address: &str) -> IPCBuilder {
namespaces::build_namespaces(IPCBuilder::new().address(address)) 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(())
} }

@ -27,3 +27,9 @@ impl From<File> for FileResponse {
} }
} }
} }
#[derive(Clone, Debug, Serialize)]
pub struct InfoResponse {
pub name: String,
pub version: String,
}

Loading…
Cancel
Save