pub struct Require {
pub ac_power: bool,
pub idle: Option<String>,
pub cpu_below: Option<f64>,
pub network: bool,
}Expand description
Host-environment gate (#418 constraints.require). Fire only when
the target host is in the required state. Sensed in-process by the
agent (Win32), so it is runs_on: agent only — the backend cannot
read a target host’s power/idle state (Schedule::validate
rejects it on runs_on: backend, symmetric with when: { on }).
Evaluated at fire time as a skip-this-tick gate (NOT in
Constraints::allows, which stays pure for preview): a reconcile
cadence re-checks every minute (so it effectively defers until the
state is met — the intended pairing); a calendar fire that lands
while the state is unmet is simply missed, same as window. It is
therefore a runtime gate and does not appear in preview.
Fields§
§ac_power: boolFire only while on AC power (skip on battery). Reads
GetSystemPowerStatus; an unknown/unreadable status is treated
as not-on-AC (fail-closed — a restrictive gate must not fire
when it can’t confirm the condition). false (default) = no
power requirement.
idle: Option<String>Fire only when the active console session has had no keyboard /
mouse input for at least this long (humantime, e.g. "10m") —
“don’t run while the user is actively working”. Input-based
(simpler than Task Scheduler’s CPU/disk-aware idle). A
headless / disconnected console (no interactive user) trivially
satisfies it. None (default) = no idle requirement. Parsed
lazily; Schedule::validate rejects garbage at create time.
cpu_below: Option<f64>Fire only when the whole-machine CPU usage is below this
percent (0–100; e.g. 20.0 = “system CPU < 20%”) — “don’t run
while the box is busy”. Reuses the agent’s host_perf system CPU%
sample (sysinfo mean over cores), so the reading is up to one
host_perf cadence old (default 60s) — fine as a “generally
busy?” proxy, and more accurate than a fresh one-shot read (CPU%
needs two samples). An unavailable sample (host_perf not warmed
up yet, or stale) is treated as “not below” (fail-closed — a
restrictive gate must not fire when it can’t confirm). None
(default) = no CPU requirement. Schedule::validate rejects an
out-of-range value at create time.
network: boolFire only when the host has internet connectivity (Windows
GetNetworkConnectivityHint reports InternetAccess) — “don’t run
until online” for jobs that download / phone home. A captive
portal (ConstrainedInternetAccess), LAN-only (LocalAccess), or
unknown/unreadable state is treated as offline (fail-closed) — a
portal would just fail a download, so we hold the run. For VPN /
SASE / app-specific conditions, use a custom script gate (separate
slice). false (default) = no network requirement.
Implementations§
Source§impl Require
impl Require
Sourcepub fn min_idle(&self) -> Option<Duration>
pub fn min_idle(&self) -> Option<Duration>
Parsed minimum-idle duration (None = no idle requirement, or an
unparseable value — validate rejects the latter at create time).
Sourcepub fn bad_idle(&self) -> Option<String>
pub fn bad_idle(&self) -> Option<String>
First unparseable field for create-time rejection (mirrors
Constraints::bad_skip_date).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Require
impl<'de> Deserialize<'de> for Require
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Require
impl JsonSchema for Require
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more