#[non_exhaustive]pub enum PolicyDecision {
Allow {
reason: Option<String>,
},
Deny {
reason: Option<String>,
},
RequiresApproval {
reason: Option<String>,
},
NotApplicable,
}Expand description
A normalized policy decision.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Allow
The call may proceed without user approval.
Deny
The call must not execute.
RequiresApproval
An external approver must decide.
NotApplicable
No approval is required, overriding the tool’s own needs_approval.
Implementations§
Source§impl PolicyDecision
impl PolicyDecision
Sourcepub fn requires_approval() -> Self
pub fn requires_approval() -> Self
Requires approval without reason.
Sourcepub fn with_reason(self, reason: impl Into<String>) -> Self
pub fn with_reason(self, reason: impl Into<String>) -> Self
Attaches a reason (ignored for NotApplicable).
Sourcepub fn normalize(raw: &JsonValue) -> Self
pub fn normalize(raw: &JsonValue) -> Self
Normalizes a raw decision document.
Recognized forms:
null: not applicable (an undefined rule or a missing result).{ "decision": "allow" | "deny" | "requires-approval" | "not-applicable", "reason"?: string }.{ "allow": bool, "reason"?: string }(legacy form).
A missing or unknown decision falls back to a valid legacy allow
field. Anything else is a denial with the reason
UNRECOGNIZED_DECISION, so that a broken policy fails closed.
Sourcepub fn into_approval(self) -> Option<ApprovalStatus>
pub fn into_approval(self) -> Option<ApprovalStatus>
Converts the decision into an approval status.
NotApplicable is an explicit status and overrides tool-defined approval.
Use crate::with_default to gate calls without a policy decision.
Trait Implementations§
Source§impl Clone for PolicyDecision
impl Clone for PolicyDecision
Source§fn clone(&self) -> PolicyDecision
fn clone(&self) -> PolicyDecision
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PolicyDecision
impl Debug for PolicyDecision
Source§impl<'de> Deserialize<'de> for PolicyDecision
impl<'de> Deserialize<'de> for PolicyDecision
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 PolicyDecision
Source§impl PartialEq for PolicyDecision
impl PartialEq for PolicyDecision
Source§impl Serialize for PolicyDecision
impl Serialize for PolicyDecision
impl StructuralPartialEq for PolicyDecision
Auto Trait Implementations§
impl Freeze for PolicyDecision
impl RefUnwindSafe for PolicyDecision
impl Send for PolicyDecision
impl Sync for PolicyDecision
impl Unpin for PolicyDecision
impl UnsafeUnpin for PolicyDecision
impl UnwindSafe for PolicyDecision
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
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,
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
Compare self to
key and return true if they are equal.