pub(crate) struct ResolvedPolicyView<P: Policy> {
organization_id: OrganizationId,
enabled: bool,
data: P::Data,
}Expand description
A PolicyView resolved against the concrete Policy that handles it.
This is the typed domain value the untyped wire PolicyView transforms into
at the boundary: the r#type discriminant has been matched and the untyped
data blob parsed into Policy::Data, so a policy can only ever be paired
with its own data type.
Fields§
§organization_id: OrganizationId§enabled: bool§data: P::DataImplementations§
Source§impl<P: Policy> ResolvedPolicyView<P>
impl<P: Policy> ResolvedPolicyView<P>
Sourcepub(crate) fn resolve(policy: &P, view: &PolicyView) -> Option<Self>
pub(crate) fn resolve(policy: &P, view: &PolicyView) -> Option<Self>
Resolves view against policy, returning Some only when the view is
the type handled by policy.
Deserializes the untyped data blob into P::Data, falling back to
Default (with a warning) when it is absent or fails to parse.
Sourcepub(crate) fn into_enforced(
self,
policy: &P,
organization_user_policy_contexts: &HashMap<OrganizationId, &OrganizationUserPolicyContext>,
) -> EnforcedPolicy<P>
pub(crate) fn into_enforced( self, policy: &P, organization_user_policy_contexts: &HashMap<OrganizationId, &OrganizationUserPolicyContext>, ) -> EnforcedPolicy<P>
Consumes the resolved view into an EnforcedPolicy, evaluating whether
policy is enforced against the user.
Pass in all organization contexts for this user; the specific context is looked up by this method so that a mismatch between policy and organization is not possible. If no context is present for the organization, the policy is enforced by default (err on the side of enforcement).
Auto Trait Implementations§
impl<P> Freeze for ResolvedPolicyView<P>
impl<P> RefUnwindSafe for ResolvedPolicyView<P>
impl<P> Send for ResolvedPolicyView<P>
impl<P> Sync for ResolvedPolicyView<P>
impl<P> Unpin for ResolvedPolicyView<P>
impl<P> UnsafeUnpin for ResolvedPolicyView<P>
impl<P> UnwindSafe for ResolvedPolicyView<P>
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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