Skip to content

Commit

Permalink
libosdp: Add a method to set multiple capabilities at once in PdInfoB…
Browse files Browse the repository at this point in the history
…uilder

Signed-off-by: Siddharth Chandrasekaran <[email protected]>
  • Loading branch information
sidcha committed Mar 24, 2024
1 parent 0025b0d commit 517d687
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions libosdp/src/pdinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ impl PdInfoBuilder {
/// Set PD ID; Static information that the PD reports to the CP when it
/// received a `CMD_ID`. For CP mode, this field is ignored, but PD mode
/// must set
pub fn id(mut self, id: PdId) -> PdInfoBuilder {
self.id = id;
pub fn id(mut self, id: &PdId) -> PdInfoBuilder {
self.id = id.clone();
self
}

Expand All @@ -92,6 +92,16 @@ impl PdInfoBuilder {
self
}

/// Set multiple capabilities at once
pub fn capabilities<'a, I>(mut self, caps: I) -> PdInfoBuilder
where I: IntoIterator<Item=&'a PdCapability>,
{
for cap in caps {
self.cap.push(cap.clone().into());
}
self
}

/// Set Osdp communication channel
pub fn channel(mut self, channel: Box<dyn Channel>) -> PdInfoBuilder {
self.channel = Some(channel);
Expand Down

0 comments on commit 517d687

Please sign in to comment.