rusp_lib/usp_builder/
getsupportedprotocol.rs

1use crate::usp::mod_Body::OneOfmsg_body::{request, response};
2use crate::usp::mod_Request::OneOfreq_type::get_supported_protocol;
3use crate::usp::mod_Response::OneOfresp_type::get_supported_protocol_resp;
4use crate::usp::{Body, GetSupportedProtocol, GetSupportedProtocolResp, Request, Response};
5
6use anyhow::Result;
7
8#[derive(Clone)]
9pub struct GetSupportedProtocolBuilder {
10    controller_supported_protocol_versions: String,
11}
12
13impl GetSupportedProtocolBuilder {
14    #[must_use]
15    pub const fn new(controller_supported_protocol_versions: String) -> Self {
16        Self {
17            controller_supported_protocol_versions,
18        }
19    }
20
21    pub fn build(self) -> Result<Body> {
22        Ok(Body {
23            msg_body: request({
24                Request {
25                    req_type: get_supported_protocol({
26                        GetSupportedProtocol {
27                            controller_supported_protocol_versions: self
28                                .controller_supported_protocol_versions,
29                        }
30                    }),
31                }
32            }),
33        })
34    }
35}
36
37#[derive(Clone)]
38pub struct GetSupportedProtocolRespBuilder {
39    agent_supported_protocol_versions: String,
40}
41
42impl GetSupportedProtocolRespBuilder {
43    #[must_use]
44    pub const fn new(agent_supported_protocol_versions: String) -> Self {
45        Self {
46            agent_supported_protocol_versions,
47        }
48    }
49
50    pub fn build(self) -> Result<Body> {
51        Ok(Body {
52            msg_body: response({
53                Response {
54                    resp_type: get_supported_protocol_resp({
55                        GetSupportedProtocolResp {
56                            agent_supported_protocol_versions: self
57                                .agent_supported_protocol_versions,
58                        }
59                    }),
60                }
61            }),
62        })
63    }
64}