pub struct StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>where
PE: PolicyEngine,
HR: HttpRequest,
IN: Installer,
TM: Timer,
MR: MetricsReporter,
ST: Storage,
AS: AppSet,
CH: Cupv2Handler,{ /* private fields */ }Expand description
Helper type to build/start a StateMachine.
Implementations§
Source§impl<PE, HR, IN, TM, MR, ST, AS, CH> StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>where
PE: PolicyEngine,
HR: HttpRequest,
IN: Installer,
TM: Timer,
MR: MetricsReporter,
ST: Storage,
AS: AppSet,
CH: Cupv2Handler,
impl<PE, HR, IN, TM, MR, ST, AS, CH> StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>where
PE: PolicyEngine,
HR: HttpRequest,
IN: Installer,
TM: Timer,
MR: MetricsReporter,
ST: Storage,
AS: AppSet,
CH: Cupv2Handler,
Source§impl<PE, HR, IN, TM, MR, ST, AS, CH> StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>where
PE: PolicyEngine,
HR: HttpRequest,
IN: Installer,
TM: Timer,
MR: MetricsReporter,
ST: Storage,
AS: AppSet,
CH: Cupv2Handler,
impl<PE, HR, IN, TM, MR, ST, AS, CH> StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>where
PE: PolicyEngine,
HR: HttpRequest,
IN: Installer,
TM: Timer,
MR: MetricsReporter,
ST: Storage,
AS: AppSet,
CH: Cupv2Handler,
Sourcepub fn policy_engine<PE2: PolicyEngine>(
self,
policy_engine: PE2,
) -> StateMachineBuilder<PE2, HR, IN, TM, MR, ST, AS, CH>
pub fn policy_engine<PE2: PolicyEngine>( self, policy_engine: PE2, ) -> StateMachineBuilder<PE2, HR, IN, TM, MR, ST, AS, CH>
Configures the state machine to use the provided policy_engine implementation.
Sourcepub fn http<HR2: HttpRequest>(
self,
http: HR2,
) -> StateMachineBuilder<PE, HR2, IN, TM, MR, ST, AS, CH>
pub fn http<HR2: HttpRequest>( self, http: HR2, ) -> StateMachineBuilder<PE, HR2, IN, TM, MR, ST, AS, CH>
Configures the state machine to use the provided http implementation.
Sourcepub fn installer<IN2: Installer>(
self,
installer: IN2,
) -> StateMachineBuilder<PE, HR, IN2, TM, MR, ST, AS, CH>
pub fn installer<IN2: Installer>( self, installer: IN2, ) -> StateMachineBuilder<PE, HR, IN2, TM, MR, ST, AS, CH>
Configures the state machine to use the provided installer implementation.
Sourcepub fn timer<TM2: Timer>(
self,
timer: TM2,
) -> StateMachineBuilder<PE, HR, IN, TM2, MR, ST, AS, CH>
pub fn timer<TM2: Timer>( self, timer: TM2, ) -> StateMachineBuilder<PE, HR, IN, TM2, MR, ST, AS, CH>
Configures the state machine to use the provided timer implementation.
Sourcepub fn metrics_reporter<MR2: MetricsReporter>(
self,
metrics_reporter: MR2,
) -> StateMachineBuilder<PE, HR, IN, TM, MR2, ST, AS, CH>
pub fn metrics_reporter<MR2: MetricsReporter>( self, metrics_reporter: MR2, ) -> StateMachineBuilder<PE, HR, IN, TM, MR2, ST, AS, CH>
Configures the state machine to use the provided metrics_reporter implementation.
Sourcepub fn storage<ST2: Storage>(
self,
storage: Rc<Mutex<ST2>>,
) -> StateMachineBuilder<PE, HR, IN, TM, MR, ST2, AS, CH>
pub fn storage<ST2: Storage>( self, storage: Rc<Mutex<ST2>>, ) -> StateMachineBuilder<PE, HR, IN, TM, MR, ST2, AS, CH>
Configures the state machine to use the provided storage implementation.
Sourcepub fn config(self, config: Config) -> Self
pub fn config(self, config: Config) -> Self
Configures the state machine to use the provided config.
Sourcepub fn app_set<AS2: AppSet>(
self,
app_set: Rc<Mutex<AS2>>,
) -> StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS2, CH>
pub fn app_set<AS2: AppSet>( self, app_set: Rc<Mutex<AS2>>, ) -> StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS2, CH>
Configures the state machine to use the provided app_set implementation.
pub fn cup_handler<CH2: Cupv2Handler>( self, cup_handler: Option<CH2>, ) -> StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH2>
Source§impl<'a, PE, HR, IN, TM, MR, ST, AS, CH, IR, PL> StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>where
PE: 'a + PolicyEngine<InstallResult = IR, InstallPlan = PL>,
HR: 'a + HttpRequest,
IN: 'a + Installer<InstallResult = IR, InstallPlan = PL>,
TM: 'a + Timer,
MR: 'a + MetricsReporter,
ST: 'a + Storage,
AS: 'a + AppSet,
CH: 'a + Cupv2Handler,
IR: 'static + Send,
PL: 'a + Plan,
impl<'a, PE, HR, IN, TM, MR, ST, AS, CH, IR, PL> StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>where
PE: 'a + PolicyEngine<InstallResult = IR, InstallPlan = PL>,
HR: 'a + HttpRequest,
IN: 'a + Installer<InstallResult = IR, InstallPlan = PL>,
TM: 'a + Timer,
MR: 'a + MetricsReporter,
ST: 'a + Storage,
AS: 'a + AppSet,
CH: 'a + Cupv2Handler,
IR: 'static + Send,
PL: 'a + Plan,
pub async fn build(self) -> StateMachine<PE, HR, IN, TM, MR, ST, AS, CH>
Sourcepub async fn start(
self,
) -> (ControlHandle, impl Stream<Item = StateMachineEvent> + 'a)
pub async fn start( self, ) -> (ControlHandle, impl Stream<Item = StateMachineEvent> + 'a)
Start the StateMachine to do periodic update checks in the background or when requested through the returned control handle. The returned stream must be polled to make forward progress.
Sourcepub async fn oneshot_check(self) -> impl Stream<Item = StateMachineEvent> + 'a
pub async fn oneshot_check(self) -> impl Stream<Item = StateMachineEvent> + 'a
Run start_upate_check once, returning a stream of the states it produces.
Trait Implementations§
Source§impl<PE, HR, IN, TM, MR, ST, AS, CH> Debug for StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>where
PE: PolicyEngine + Debug,
HR: HttpRequest + Debug,
IN: Installer + Debug,
TM: Timer + Debug,
MR: MetricsReporter + Debug,
ST: Storage + Debug,
AS: AppSet + Debug,
CH: Cupv2Handler + Debug,
impl<PE, HR, IN, TM, MR, ST, AS, CH> Debug for StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>where
PE: PolicyEngine + Debug,
HR: HttpRequest + Debug,
IN: Installer + Debug,
TM: Timer + Debug,
MR: MetricsReporter + Debug,
ST: Storage + Debug,
AS: AppSet + Debug,
CH: Cupv2Handler + Debug,
Auto Trait Implementations§
impl<PE, HR, IN, TM, MR, ST, AS, CH> !RefUnwindSafe for StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>
impl<PE, HR, IN, TM, MR, ST, AS, CH> !Send for StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>
impl<PE, HR, IN, TM, MR, ST, AS, CH> !Sync for StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>
impl<PE, HR, IN, TM, MR, ST, AS, CH> !UnwindSafe for StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>
impl<PE, HR, IN, TM, MR, ST, AS, CH> Freeze for StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>
impl<PE, HR, IN, TM, MR, ST, AS, CH> Unpin for StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>
impl<PE, HR, IN, TM, MR, ST, AS, CH> UnsafeUnpin for StateMachineBuilder<PE, HR, IN, TM, MR, ST, AS, CH>where
PE: UnsafeUnpin,
HR: UnsafeUnpin,
IN: UnsafeUnpin,
TM: UnsafeUnpin,
MR: UnsafeUnpin,
CH: UnsafeUnpin,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);