xnode_manager_sdk/request/
handlers.rs1use crate::{
2 request::{CommandInfo, RequestInfo, models::RequestId},
3 utils::{Empty, SessionGetInput, SessionGetOutput, session_get},
4};
5
6pub fn scope() -> String {
7 "/request".to_string()
8}
9
10#[derive(Debug, Clone, PartialEq)]
11pub struct RequestInfoPath {
12 pub request_id: RequestId,
13}
14pub type RequestInfoInput<'a> = SessionGetInput<'a, RequestInfoPath, Empty>;
15pub type RequestInfoOutput = RequestInfo;
16pub async fn request_info(input: RequestInfoInput<'_>) -> SessionGetOutput<RequestInfoOutput> {
17 session_get(input, scope(), |path| {
18 format!("/{request_id}/info", request_id = path.request_id)
19 })
20 .await
21}
22
23#[derive(Debug, Clone, PartialEq)]
24pub struct CommandInfoPath {
25 pub request_id: RequestId,
26 pub command: String,
27}
28pub type CommandInfoInput<'a> = SessionGetInput<'a, CommandInfoPath, Empty>;
29pub type CommandInfoOutput = CommandInfo;
30pub async fn command_info(input: CommandInfoInput<'_>) -> SessionGetOutput<CommandInfoOutput> {
31 session_get(input, scope(), |path| {
32 format!(
33 "/{request_id}/command/{command}/info",
34 request_id = path.request_id,
35 command = path.command
36 )
37 })
38 .await
39}