Skip to content

Commit 154d1da

Browse files
Member functions
1 parent fccfe4f commit 154d1da

File tree

1 file changed

+15
-1
lines changed
  • rust/rbac-registration/src/cardano/cip509

1 file changed

+15
-1
lines changed

rust/rbac-registration/src/cardano/cip509/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use validation::{
2727
use super::transaction::witness::TxWitness;
2828
use crate::{
2929
cardano::cip509::{
30-
rbac::Cip509RbacMetadata,
30+
rbac::{Cip509RbacMetadata, RoleData, RoleNumber},
3131
types::{TxInputHash, ValidationSignature},
3232
x509_chunks::X509Chunks,
3333
},
@@ -171,6 +171,20 @@ impl Cip509 {
171171
}
172172
}
173173

174+
/// Returns all role numbers present in this `Cip509` instance.
175+
pub fn all_roles(&self) -> Vec<RoleNumber> {
176+
self.metadata
177+
.map(|m| m.role_data.keys())
178+
.iter()
179+
.flatten()
180+
.collect()
181+
}
182+
183+
/// Returns a role data for the given role if it is present.
184+
pub fn role_data(&self, role: RoleNumber) -> Option<&RoleData> {
185+
self.metadata.and_then(|m| m.role_data.get(&role))
186+
}
187+
174188
// TODO: FIXME: Consume fields in the registration chain, use methods everywhere else.
175189
// /// Returns a registration purpose.
176190
// #[must_use]

0 commit comments

Comments
 (0)