Skip to main content

Env

Struct Env 

Source
pub struct Env {
    pub runner: Arc<dyn CommandRunner>,
    pub out: SharedWriter,
    pub err: SharedWriter,
    pub cwd: PathBuf,
    pub env: Arc<dyn EnvProvider>,
    pub time: Arc<dyn TimeProvider>,
    pub vertex: ReasoningEngineOptions,
}
Expand description

Everything a command reads or writes outside the process (stdout, stderr, the working directory, the environment, the clock and child processes).

Fields§

§runner: Arc<dyn CommandRunner>

Launches child processes (gcloud, cargo metadata).

§out: SharedWriter

Standard output: step banners, printer lines and child output.

§err: SharedWriter

Standard error: the Error: line and usage.

§cwd: PathBuf

The working directory: relative paths resolve against it.

§env: Arc<dyn EnvProvider>

The environment (PATH for command lookup, TMPDIR for the temp dir).

§time: Arc<dyn TimeProvider>

The clock.

§vertex: ReasoningEngineOptions

How gadk deploy agentengine reaches Vertex AI (endpoint, credentials and HTTP client are injectable for tests). An unset ReasoningEngineOptions::env means Env::env.

Implementations§

Source§

impl Env

Source

pub fn new( runner: Arc<dyn CommandRunner>, out: SharedWriter, err: SharedWriter, cwd: PathBuf, env: Arc<dyn EnvProvider>, time: Arc<dyn TimeProvider>, ) -> Env

An Env from its parts, with default Vertex options (tests set Env::vertex on the built value). Outside this file an Env is built only here, by Env::process or by the test builder, never by a struct literal.

Source

pub fn process() -> Env

The production environment: real processes, stdout/stderr, the current directory (empty when it cannot be read), the process environment, the system clock and Vertex AI at its regional endpoint with Application Default Credentials.

Source

pub fn abs(&self, path: &str) -> PathBuf

Resolves path against Env::cwd: an absolute path is cleaned, a relative one is joined to the working directory and cleaned; "" is the working directory.

Source

pub fn temp_dir(&self) -> PathBuf

The temp dir on Unix: $TMPDIR, else /tmp.

Source

pub fn command(&self, name: &str, args: &[&str]) -> Cmd

A command for name with args, looked up in PATH read from Env::env.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Env

§

impl !UnwindSafe for Env

§

impl Forget for Env

§

impl Freeze for Env

§

impl Move for Env

§

impl Send for Env

§

impl Sync for Env

§

impl Unpin for Env

§

impl UnsafeUnpin for Env

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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