pub struct Context<R: Runtime + ?Sized> {
pub cli: <R as RuntimeDef>::Cli,
pub conf: <R as RuntimeDef>::Conf,
pub conf_path: PathBuf,
pub env: Box<dyn Env<<R as RuntimeDef>::Cli>>,
pub emitter: Option<EventEmitter>,
/* private fields */
}
Expand description
Runtime execution context
Fields§
§cli: <R as RuntimeDef>::Cli
Command line parameters
conf: <R as RuntimeDef>::Conf
Configuration read from the configuration file
conf_path: PathBuf
Configuration file path
env: Box<dyn Env<<R as RuntimeDef>::Cli>>
Environment instance
emitter: Option<EventEmitter>
Event emitter, available when
Runtime::MODE == RuntimeMode::Server
and
command != Command::Deploy
Implementations§
Source§impl<R> Context<R>
impl<R> Context<R>
Sourcepub fn try_new() -> Result<Self>
pub fn try_new() -> Result<Self>
Create a new instance with a default environment configuration
Sourcepub fn try_with<E>(env: E) -> Result<Self>
pub fn try_with<E>(env: E) -> Result<Self>
Create a new instance with provided environment configuration
Sourcepub fn read_config<P: AsRef<Path>>(path: P) -> Result<<R as RuntimeDef>::Conf>
pub fn read_config<P: AsRef<Path>>(path: P) -> Result<<R as RuntimeDef>::Conf>
Read configuration from file
Sourcepub fn write_config<P: AsRef<Path>>(
conf: &<R as RuntimeDef>::Conf,
path: P,
) -> Result<()>
pub fn write_config<P: AsRef<Path>>( conf: &<R as RuntimeDef>::Conf, path: P, ) -> Result<()>
Write configuration to file
Sourcepub fn control(&self) -> RuntimeControl
pub fn control(&self) -> RuntimeControl
Return a runtime control object
Auto Trait Implementations§
impl<R> !Freeze for Context<R>
impl<R> !RefUnwindSafe for Context<R>
impl<R> !Send for Context<R>
impl<R> !Sync for Context<R>
impl<R> Unpin for Context<R>
impl<R> !UnwindSafe for Context<R>
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