pub struct Resource { /* private fields */ }Expand description
A resource represents something that can be accessed or acted upon.
Implementations§
Source§impl Resource
impl Resource
Sourcepub fn new(id: impl Into<String>, resource_type: impl Into<String>) -> Self
pub fn new(id: impl Into<String>, resource_type: impl Into<String>) -> Self
Create a new resource.
Sourcepub fn resource_type(&self) -> &str
pub fn resource_type(&self) -> &str
Get the resource type.
Sourcepub fn with_attribute(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_attribute( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add an attribute to the resource.
Sourcepub fn set_attribute(
&mut self,
key: impl Into<String>,
value: impl Into<String>,
)
pub fn set_attribute( &mut self, key: impl Into<String>, value: impl Into<String>, )
Set an attribute on the resource.
Sourcepub fn attributes(&self) -> &HashMap<String, String>
pub fn attributes(&self) -> &HashMap<String, String>
Get all attributes.
Sourcepub fn remove_attribute(&mut self, key: &str) -> Option<String>
pub fn remove_attribute(&mut self, key: &str) -> Option<String>
Remove an attribute.
Sourcepub fn has_attribute(&self, key: &str) -> bool
pub fn has_attribute(&self, key: &str) -> bool
Check if the resource has a specific attribute.
Sourcepub fn effective_name(&self) -> &str
pub fn effective_name(&self) -> &str
Get the effective name for display purposes.
Sourcepub fn matches_pattern(&self, pattern: &str) -> bool
pub fn matches_pattern(&self, pattern: &str) -> bool
Check if this resource matches a pattern. Patterns can include wildcards (*) and hierarchical matching.
Sourcepub fn is_under_path(&self, parent_path: &str) -> bool
pub fn is_under_path(&self, parent_path: &str) -> bool
Check if the resource is within a specific parent path.
Sourcepub fn parent_path(&self) -> Option<String>
pub fn parent_path(&self) -> Option<String>
Get the parent path of this resource.
Trait Implementations§
impl Eq for Resource
impl StructuralPartialEq for Resource
Auto Trait Implementations§
impl Freeze for Resource
impl RefUnwindSafe for Resource
impl Send for Resource
impl Sync for Resource
impl Unpin for Resource
impl UnwindSafe for Resource
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