pub struct RoleCatalog {
roles: HashMap<RoleId, RoleSpec>,
}Expand description
Immutable map of RoleId → RoleSpec for the built-in specialist roles.
Construct via RoleCatalog::default(); the seven built-in roles are
always present. YAML-overridable catalogs are deferred to a future phase.
§Example
use gglib_core::domain::council::role_catalog::{RoleCatalog, RoleId};
let catalog = RoleCatalog::default();
assert_eq!(catalog.len(), 7);
assert!(catalog.get(&RoleId::new("researcher")).is_some());
assert!(catalog.get(&RoleId::new("unknown-role")).is_none());Fields§
§roles: HashMap<RoleId, RoleSpec>Implementations§
Source§impl RoleCatalog
impl RoleCatalog
Sourcepub fn get(&self, id: &RoleId) -> Option<&RoleSpec>
pub fn get(&self, id: &RoleId) -> Option<&RoleSpec>
Look up a role by id.
Returns None if no role with the given id exists in the catalog.
§Example
use gglib_core::domain::council::role_catalog::{RoleCatalog, RoleId};
let catalog = RoleCatalog::default();
let spec = catalog.get(&RoleId::new("writer")).unwrap();
assert_eq!(spec.display_name, "Writer");
assert!(catalog.get(&RoleId::new("nonexistent")).is_none());Trait Implementations§
Auto Trait Implementations§
impl Freeze for RoleCatalog
impl RefUnwindSafe for RoleCatalog
impl Send for RoleCatalog
impl Sync for RoleCatalog
impl Unpin for RoleCatalog
impl UnwindSafe for RoleCatalog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more