pub struct GroupsView<'a> { /* private fields */ }Expand description
A view over the groups collection in an inventory that applies transform functions on access.
This struct provides a read-only view of the groups stored in an Inventory. When accessing
individual groups through this view, any configured transform function is automatically applied.
The view caches transformed results to improve performance on subsequent accesses to the same group.
The view does not own the inventory data; it holds references to both the parent Inventory and
the underlying Groups collection. It provides methods to iterate over groups, look up groups by
name, and query collection metadata.
§Lifetime
'a- The lifetime of the references to the parentInventoryandGroupscollection. The view cannot outlive either the inventory or groups it references.
§Examples
let mut groups = Groups::new();
groups.add_group("core", Group::builder().platform("linux").build());
let inventory = Inventory::builder().groups(groups).build();
if let Some(groups_view) = inventory.groups() {
assert_eq!(groups_view.len(), 1);
if let Some(group) = groups_view.get("core") {
assert_eq!(group.platform(), Some("linux"));
}
for (name, group) in groups_view.iter() {
println!("Group: {}", name);
}
}Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for GroupsView<'a>
impl<'a> !UnwindSafe for GroupsView<'a>
impl<'a> Freeze for GroupsView<'a>
impl<'a> Send for GroupsView<'a>
impl<'a> Sync for GroupsView<'a>
impl<'a> Unpin for GroupsView<'a>
impl<'a> UnsafeUnpin for GroupsView<'a>
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