Skip to main content

ActionContext

Struct ActionContext 

Source
pub struct ActionContext {
    pub action: String,
    pub payload_summary: String,
    pub payload_body: Option<String>,
    pub attributes: BTreeMap<String, Value>,
}
Expand description

Everything a Check needs to make its decision about a proposed action.

The core never inspects attributes; only checks do. That is what keeps the context domain-neutral: OAP’s diff_lines / spec_statuses / max_spec_risk and chancery’s fact_sheet_id / investor_id all live in attributes, read only by the checks that understand them.

Fields§

§action: String

The action being proposed, e.g. "email.send", "workspace.write_file". (OAP’s tool_name.)

§payload_summary: String

A canonical string form of the payload, for scanning. (OAP’s arguments_summary.)

§payload_body: Option<String>

The full content under review, when there is one. (OAP’s proposed_file_content.)

§attributes: BTreeMap<String, Value>

Everything domain-specific, keyed by name. Checks read what they need.

Implementations§

Source§

impl ActionContext

Source

pub fn new(action: impl Into<String>) -> ActionContext

A context for action with an empty payload and no attributes.

Source

pub fn with_summary(self, summary: impl Into<String>) -> ActionContext

Builder: set the payload summary (the string checks scan).

Source

pub fn with_body(self, body: impl Into<String>) -> ActionContext

Builder: set the payload body (the full content under review).

Source

pub fn with_attr(self, key: impl Into<String>, value: Value) -> ActionContext

Builder: insert a domain attribute.

Source

pub fn attr_str(&self, key: &str) -> Option<&str>

Read an attribute as a string, if present and a string.

Source

pub fn attr(&self, key: &str) -> Option<&Value>

Read a raw attribute value.

Trait Implementations§

Source§

impl Clone for ActionContext

Source§

fn clone(&self) -> ActionContext

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActionContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ActionContext

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<ActionContext, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ActionContext

Source§

impl PartialEq for ActionContext

Source§

fn eq(&self, other: &ActionContext) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ActionContext

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ActionContext

Auto Trait Implementations§

§

impl Forget for ActionContext

§

impl Freeze for ActionContext
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const LeafNode<String, Value> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Value)>>: Freeze,

§

impl Move for ActionContext

§

impl RefUnwindSafe for ActionContext

§

impl Send for ActionContext
where RawVecInner: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send,

§

impl Sync for ActionContext
where RawVecInner: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync,

§

impl Unpin for ActionContext
where *const u8 is !null: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin,

§

impl UnsafeUnpin for ActionContext
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const LeafNode<String, Value> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, Value)>>: UnsafeUnpin,

§

impl UnwindSafe for ActionContext
where RawVecInner: UnwindSafe, BTreeMap<String, Value>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.