pub struct ExecutionContext {
pub non_interactive: bool,
pub trace_id: Option<String>,
pub max_cost_credits: Option<u32>,
pub budget_daily_credits: Option<u32>,
pub dry_run: bool,
}Expand description
Execution context for commands
Fields§
§non_interactive: boolWhether running in non-interactive mode
trace_id: Option<String>Optional trace ID for request correlation
max_cost_credits: Option<u32>Maximum cost in credits for a single operation
budget_daily_credits: Option<u32>Daily budget in credits
dry_run: boolDry run mode
Implementations§
Source§impl ExecutionContext
impl ExecutionContext
Sourcepub fn new(
non_interactive: bool,
trace_id: Option<String>,
max_cost_credits: Option<u32>,
budget_daily_credits: Option<u32>,
dry_run: bool,
) -> Self
pub fn new( non_interactive: bool, trace_id: Option<String>, max_cost_credits: Option<u32>, budget_daily_credits: Option<u32>, dry_run: bool, ) -> Self
Create a new execution context
Sourcepub fn check_interaction_required(
&self,
message: impl Into<String>,
next_steps: Vec<String>,
) -> Option<ErrorDetails>
pub fn check_interaction_required( &self, message: impl Into<String>, next_steps: Vec<String>, ) -> Option<ErrorDetails>
Check if authentication is required and return an error if in non-interactive mode
This helper should be called by commands that need authentication or user interaction. If in non-interactive mode, it returns an AUTH_REQUIRED error with next steps. Otherwise, it allows the command to proceed with interactive prompts.
§Example
use xcom_rs::context::ExecutionContext;
let ctx = ExecutionContext::new(true, None, None, None, false);
let error = ctx.check_interaction_required(
"Authentication required",
vec!["Run 'xcom-rs auth login' first".to_string()]
);
// If error.is_some(), handle the interaction requirement
assert!(error.is_some());Sourcepub fn check_max_cost(&self, cost: &CostEstimate) -> Option<ErrorDetails>
pub fn check_max_cost(&self, cost: &CostEstimate) -> Option<ErrorDetails>
Check if cost exceeds maximum allowed
Sourcepub fn check_daily_budget(
&self,
cost: &CostEstimate,
tracker: &BudgetTracker,
) -> Option<ErrorDetails>
pub fn check_daily_budget( &self, cost: &CostEstimate, tracker: &BudgetTracker, ) -> Option<ErrorDetails>
Check if cost would exceed daily budget
Trait Implementations§
Source§impl Clone for ExecutionContext
impl Clone for ExecutionContext
Source§fn clone(&self) -> ExecutionContext
fn clone(&self) -> ExecutionContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ExecutionContext
impl RefUnwindSafe for ExecutionContext
impl Send for ExecutionContext
impl Sync for ExecutionContext
impl Unpin for ExecutionContext
impl UnwindSafe for ExecutionContext
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