Skip to content

Commit

Permalink
feat: add dedicated attributes_properties to get dimension attribut…
Browse files Browse the repository at this point in the history
…es in order
  • Loading branch information
Hugo Rosenkranz-Costa committed Oct 25, 2023
1 parent d245676 commit 6e127c5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/abe_policy/dimension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,25 @@ impl Dimension {
})
.ok_or(Error::AttributeNotFound(attr_name.to_string()))
}

/// Returns the list of Attributes of this Policy.
/// If the dimension is ordered, the attributes are returned in order.
pub fn attributes_properties(&self) -> Vec<(String, EncryptionHint)> {
if let Some(ordered_attrs) = &self.order {
ordered_attrs
.iter()
.map(|name| {
(
name.to_string(),
self.attributes.get(name).unwrap().encryption_hint,
)
})
.collect()
} else {
self.attributes
.iter()
.map(|(name, attr_params)| (name.to_string(), attr_params.encryption_hint))
.collect()
}
}
}

0 comments on commit 6e127c5

Please sign in to comment.