Skip to main content

HostContext

Struct HostContext 

Source
pub struct HostContext {
    pub mode: ApplyMode,
    pub paths: HostPaths,
    pub setup_kind: SetupKind,
    pub skip_piper: bool,
    pub apply_nat: bool,
    pub logs: Vec<String>,
    pub planned: Vec<PlannedAction>,
    prompts: Option<Box<dyn PromptsProvider>>,
    pub prompt_answers: HashMap<String, String>,
}
Expand description

Mutable per-run state passed into steps and kits.

Fields§

§mode: ApplyMode

Dry-run vs apply.

§paths: HostPaths

Host filesystem layout for this run.

§setup_kind: SetupKind

Selected Full / Minimal pipeline.

§skip_piper: bool

When true, Piper-related install paths are skipped.

§apply_nat: bool

When true, NAT-related confirms auto-accept (also set via HORTO_APPLY_NAT).

§logs: Vec<String>

Accumulated log lines for TUI / API surfaces (also mirrored to tracing).

§planned: Vec<PlannedAction>

Planned actions collected during dry-run / plan.

§prompts: Option<Box<dyn PromptsProvider>>§prompt_answers: HashMap<String, String>

Pre-filled answers keyed by prompt label (tests / automation).

Implementations§

Source§

impl HostContext

Source

pub fn new(mode: ApplyMode, kind: SetupKind) -> Self

Create a context with default HostPaths and empty logs / planned actions.

apply_nat is initialized from HORTO_APPLY_NAT=1 / true when set.

Source

pub fn with_paths(self, paths: HostPaths) -> Self

Replace host paths (tests and alternate roots).

Source

pub fn with_prompts(self, prompts: Box<dyn PromptsProvider>) -> Self

Attach an interactive or recording prompts provider.

Source

pub fn log(&mut self, msg: impl AsRef<str>)

Append a log line and emit tracing::info!.

Source

pub fn plan_action(&mut self, summary: impl Into<String>)

Record a planned action, log it with a [plan] prefix, and push onto Self::planned.

Source

pub fn is_dry_run(&self) -> bool

Source

pub fn prompt(&mut self, label: &str, default: &str) -> String

Resolve a prompt: prefer Self::prompt_answers, then the prompts provider, else default.

Source

pub fn confirm(&mut self, question: &str, default_yes: bool) -> bool

Resolve a yes/no confirm.

When Self::apply_nat is set and question contains "nat" (ASCII case-insensitive), returns true without asking. Otherwise uses the prompts provider or default_yes.

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more