Switchyard

Struct Switchyard 

Source
pub struct Switchyard<E: FactsEmitter, A: AuditSink> { /* private fields */ }
Expand description

Facade for orchestrating Switchyard stages over a configured Policy and adapters.

Construct via ApiBuilder or Switchyard::builder and then call plan, preflight, and apply in sequence. The type parameters E and A are emitter types implementing FactsEmitter and AuditSink, respectively.

Implementations§

Source§

impl<E: FactsEmitter, A: AuditSink> Switchyard<E, A>

Source

pub fn new(facts: E, audit: A, policy: Policy) -> Self

Construct a Switchyard with defaults. This function delegates to the builder.

This delegates to ApiBuilder::new(facts, audit, policy).build() to avoid duplicating initialization logic.

Source

pub fn builder(facts: E, audit: A, policy: Policy) -> ApiBuilder<E, A>

Entrypoint for constructing via the builder (default construction path).

Prefer this over new so you can configure optional adapters and timeouts.

Source

pub fn with_lock_manager(self, lock: Box<dyn DebugLockManager>) -> Self

Configure via ApiBuilder::with_lock_manager.

Source

pub fn with_overrides(self, overrides: Overrides) -> Self

Configure per-instance overrides for simulations (tests/controlled scenarios).

Source

pub fn overrides(&self) -> &Overrides

Access the current per-instance overrides.

Source

pub fn with_ownership_oracle(self, owner: Box<dyn DebugOwnershipOracle>) -> Self

Configure via ApiBuilder::with_ownership_oracle.

Source

pub fn with_attestor(self, attest: Box<dyn DebugAttestor>) -> Self

Configure via ApiBuilder::with_attestor.

Source

pub fn with_smoke_runner(self, smoke: Box<dyn DebugSmokeTestRunner>) -> Self

Configure via ApiBuilder::with_smoke_runner.

Source

pub const fn with_lock_timeout_ms(self, timeout_ms: u64) -> Self

Configure via ApiBuilder::with_lock_timeout_ms.

Source

pub fn plan(&self, input: PlanInput) -> Plan

Build a Plan from the provided PlanInput with stable action ordering.

This emits planning facts and returns a Plan suitable for preflight and apply.

Source

pub fn preflight(&self, plan: &Plan) -> Result<PreflightReport, ApiError>

Execute preflight analysis for a plan.

Returns a PreflightReport containing rows (one per action), warnings, and stops.

§Errors

Returns an ApiError if the preflight analysis fails.

Source

pub fn apply( &self, plan: &Plan, mode: ApplyMode, ) -> Result<ApplyReport, ApiError>

Apply a plan in the specified mode.

Returns an ApplyReport with execution results. In Commit mode, missing required adapters such as a LockManager may be mapped to ApiError::LockingTimeout.

§Errors

Returns an ApiError if the plan application fails.

Source

pub fn plan_rollback_of(&self, report: &ApplyReport) -> Plan

Construct a rollback Plan that inverses executed actions from an ApplyReport.

Emits a planning fact for visibility and then builds the inverse plan.

Source

pub fn prune_backups(&self, target: &SafePath) -> Result<PruneResult, ApiError>

Prune backup artifacts for a given target according to retention policy.

Emits a prune.result fact with details about counts and policy used.

§Errors

Returns an ApiError if backup pruning fails.

Trait Implementations§

Source§

impl<E: Debug + FactsEmitter, A: Debug + AuditSink> Debug for Switchyard<E, A>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<E, A> Freeze for Switchyard<E, A>
where E: Freeze, A: Freeze,

§

impl<E, A> !RefUnwindSafe for Switchyard<E, A>

§

impl<E, A> Send for Switchyard<E, A>
where E: Send, A: Send,

§

impl<E, A> Sync for Switchyard<E, A>
where E: Sync, A: Sync,

§

impl<E, A> Unpin for Switchyard<E, A>
where E: Unpin, A: Unpin,

§

impl<E, A> !UnwindSafe for Switchyard<E, A>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.