Skip to main content

Context

Struct Context 

Source
pub struct Context<'a> { /* private fields */ }
Expand description

Execution context handed to every middleware.

Implementations§

Source§

impl<'a> Context<'a>

Source

pub fn new(host: &'a dyn Host, working_dir: String, step_name: String) -> Self

Source

pub fn with_state(self, state: &'a dyn Any) -> Self

Source

pub fn with_plugin_config(self, cfg: &'a dyn Any) -> Self

Source

pub fn log_debug(&self, msg: &str)

Source

pub fn log_info(&self, msg: &str)

Source

pub fn log_warn(&self, msg: &str)

Source

pub fn log_error(&self, msg: &str)

Source

pub fn progress(&self, msg: &str)

Source

pub fn working_dir(&self) -> &str

Source

pub fn step_name(&self) -> &str

Source

pub fn get_config(&self, path: &str) -> Option<Value>

Raw accumulated config at path (:-separated), parsed from json-value.

Source

pub fn get_config_as<T: DeserializeOwned>(&self, path: &str) -> Option<T>

Config at path, coerced (§5.4) into T. None if absent or on error.

Source

pub fn env(&self) -> Env<'a>

Environment access.

Source

pub fn clock(&self) -> Clock<'a>

Monotonic clock access.

Source

pub fn random(&self) -> Random<'a>

Randomness access.

Source

pub fn command(&self, program: impl Into<String>) -> Command<'a>

Subprocess builder for program.

Source

pub fn http(&self) -> Http<'a>

Blocking HTTP client.

Source

pub fn state<T: 'static>(&self) -> &T

The plugin’s shared state. Panics if the plugin declared no state:.

Source

pub fn plugin_config<T: 'static>(&self) -> &T

The typed plugin-level config. Panics if the plugin declared no config:.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Context<'a>

§

impl<'a> !Send for Context<'a>

§

impl<'a> !Sync for Context<'a>

§

impl<'a> !UnwindSafe for Context<'a>

§

impl<'a> Freeze for Context<'a>

§

impl<'a> Unpin for Context<'a>

§

impl<'a> UnsafeUnpin for Context<'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> Resource for T
where T: 'static,

Source§

type Rep = Option<T>

The type which is actually stored in-memory for this resource. 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.