pub struct RuleType(/* private fields */);Expand description
Open subject-dimension vocabulary bound to access_control_rules.rule_type.
Core mints exactly two: RuleType::USER and RuleType::ROLE. Every
other dimension (department, cost centre, clearance, …) is an extension
concern, minted with RuleType::extension and taught to the resolver via
a SubjectDimension registered by
register_subject_attribute_provider!. Core never interprets an
extension slug.
This mirrors AuthzContext: the column is an open vocabulary
validated at the Rust boundary rather than by a SQL CHECK, so an
unrecognised-but-well-formed slug is data, not an error.
Implementations§
Source§impl RuleType
impl RuleType
Sourcepub fn extension(slug: impl Into<Cow<'static, str>>) -> Result<Self, AuthzError>
pub fn extension(slug: impl Into<Cow<'static, str>>) -> Result<Self, AuthzError>
Mints an extension-owned dimension slug.
§Errors
Returns AuthzError::InvalidRuleType when the slug is empty, is not
lowercase snake_case, or collides with a core built-in. The shape
requirement keeps dimensions from independent extensions from
colliding with each other or with user / role.
pub fn as_str(&self) -> &str
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RuleType
impl<'de> Deserialize<'de> for RuleType
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>,
Source§impl<'q> Encode<'q, Postgres> for RuleType
impl<'q> Encode<'q, Postgres> for RuleType
Source§fn encode_by_ref(
&self,
buf: &mut <Postgres as Database>::ArgumentBuffer,
) -> Result<IsNull, BoxDynError>
fn encode_by_ref( &self, buf: &mut <Postgres as Database>::ArgumentBuffer, ) -> Result<IsNull, BoxDynError>
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
impl Eq for RuleType
Source§impl From<&str> for RuleType
impl From<&str> for RuleType
Source§fn from(s: &str) -> Self
fn from(s: &str) -> Self
A rule type read back from storage is data, not input: an extension
dimension core has never heard of round-trips instead of poisoning the
read. Minting a new slug goes through RuleType::extension, which
is where the shape rules are enforced.
Source§impl Ord for RuleType
impl Ord for RuleType
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for RuleType
impl PartialOrd for RuleType
impl StructuralPartialEq for RuleType
Auto Trait Implementations§
impl Freeze for RuleType
impl RefUnwindSafe for RuleType
impl Send for RuleType
impl Sync for RuleType
impl Unpin for RuleType
impl UnsafeUnpin for RuleType
impl UnwindSafe for RuleType
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more