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_checked(
id: impl Into<String>,
resource_type: impl Into<String>,
) -> Result<Resource, Error>
pub fn new_checked( id: impl Into<String>, resource_type: impl Into<String>, ) -> Result<Resource, Error>
Create a new resource with validation.
§Errors
Returns a ValidationError
if the ID or resource type contains path traversal
sequences or null characters.
Sourcepub fn new(id: impl Into<String>, resource_type: impl Into<String>) -> Resource
pub fn new(id: impl Into<String>, resource_type: impl Into<String>) -> Resource
Create a new resource.
§Panics
This method panics if the ID or resource type contains path traversal
sequences or null characters. For non-panicking validation, use new_checked
.
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>,
) -> Resource
pub fn with_attribute( self, key: impl Into<String>, value: impl Into<String>, ) -> Resource
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§
Source§impl<'de> Deserialize<'de> for Resource
impl<'de> Deserialize<'de> for Resource
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Resource, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Resource, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Resource
impl Serialize for Resource
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.