pub struct Resource { /* private fields */ }Expand description
A resource to be protected by authorization.
use stateset_authz::Resource;
let orders = Resource::new("orders");
assert_eq!(orders.resource_type(), "orders");
assert!(orders.resource_id().is_none());
let order = Resource::with_id("orders", "ord_123");
assert_eq!(order.resource_id(), Some("ord_123"));Implementations§
Source§impl Resource
impl Resource
Sourcepub fn new(resource_type: impl Into<String>) -> Self
pub fn new(resource_type: impl Into<String>) -> Self
Creates a resource with only a type (e.g., “orders”).
Sourcepub fn with_id(
resource_type: impl Into<String>,
resource_id: impl Into<String>,
) -> Self
pub fn with_id( resource_type: impl Into<String>, resource_id: impl Into<String>, ) -> Self
Creates a resource with a type and a specific ID.
Sourcepub fn resource_type(&self) -> &str
pub fn resource_type(&self) -> &str
Returns the resource type (e.g., “orders”, “customers”).
Sourcepub fn resource_id(&self) -> Option<&str>
pub fn resource_id(&self) -> Option<&str>
Returns the optional resource ID.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Resource
impl<'de> Deserialize<'de> for Resource
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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 UnsafeUnpin 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