Skip to content

Commit

Permalink
Rename builder function and add GSDM object access setters
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Egger <[email protected]>
  • Loading branch information
therealprof committed Sep 12, 2024
1 parent c05fd8a commit 2fd91b5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/usp_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub use getinstances::{
};
pub use getsupporteddm::{
GSDMCommandResult, GSDMEventResult, GSDMParamResult, GSDMReqObjectResultBuilder,
GSDMSupportedObjectResult, GetSupportedDMBuilder, GetSupportedDMRespBuilder,
GSDMSupportedObjectResultBuilder, GetSupportedDMBuilder, GetSupportedDMRespBuilder,
};
pub use getsupportedprotocol::{GetSupportedProtocolBuilder, GetSupportedProtocolRespBuilder};
pub use msg::MsgBuilder;
Expand Down
34 changes: 29 additions & 5 deletions src/usp_builder/getsupporteddm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl GSDMParamResult {
}

#[derive(Clone)]
pub struct GSDMSupportedObjectResult {
pub struct GSDMSupportedObjectResultBuilder {
supported_obj_path: String,
access: ObjAccessType,
is_multi_instance: bool,
Expand All @@ -334,7 +334,7 @@ pub struct GSDMSupportedObjectResult {
unique_key_sets: Vec<Vec<String>>,
}

impl GSDMSupportedObjectResult {
impl GSDMSupportedObjectResultBuilder {
#[must_use]
pub const fn new(supported_obj_path: String) -> Self {
Self {
Expand All @@ -349,6 +349,30 @@ impl GSDMSupportedObjectResult {
}
}

#[must_use]
pub const fn set_access_add_only(mut self) -> Self {
self.access = ObjAccessType::OBJ_ADD_ONLY;
self
}

#[must_use]
pub const fn set_access_delete_only(mut self) -> Self {
self.access = ObjAccessType::OBJ_DELETE_ONLY;
self
}

#[must_use]
pub const fn set_access_read_only(mut self) -> Self {
self.access = ObjAccessType::OBJ_READ_ONLY;
self
}

#[must_use]
pub const fn set_access_add_delete(mut self) -> Self {
self.access = ObjAccessType::OBJ_ADD_DELETE;
self
}

#[must_use]
pub const fn with_is_multi_instance(mut self, is_multi_instance: bool) -> Self {
self.is_multi_instance = is_multi_instance;
Expand Down Expand Up @@ -435,7 +459,7 @@ pub struct GSDMReqObjectResultBuilder {
err_code: u32,
err_msg: Option<String>,
data_model_inst_uri: String,
supported_objs: Vec<GSDMSupportedObjectResult>,
supported_objs: Vec<GSDMSupportedObjectResultBuilder>,
}

impl GSDMReqObjectResultBuilder {
Expand Down Expand Up @@ -465,7 +489,7 @@ impl GSDMReqObjectResultBuilder {
}

#[must_use]
pub fn with_supported_objs(mut self, supported_objs: Vec<GSDMSupportedObjectResult>) -> Self {
pub fn with_supported_objs(mut self, supported_objs: Vec<GSDMSupportedObjectResultBuilder>) -> Self {
self.supported_objs = supported_objs;
self
}
Expand All @@ -479,7 +503,7 @@ impl GSDMReqObjectResultBuilder {
let supported_objs = self
.supported_objs
.into_iter()
.map(GSDMSupportedObjectResult::build)
.map(GSDMSupportedObjectResultBuilder::build)
.collect::<Result<Vec<_>>>()?;

Ok(RequestedObjectResult {
Expand Down

0 comments on commit 2fd91b5

Please sign in to comment.