pub struct Owner { /* private fields */ }Expand description
One owner’s configuration, as a pure state machine (§2.6 to §2.17).
Every method takes the instant it acts at. A call is answered by a
Step: Step::Done now, or Step::Act, an act the runtime
performs on the device before it calls Owner::finish with the
result. While an act is in flight, every call is busy (§2.7). The
runtime calls Owner::due at Owner::next_due, for the deadline’s
undo and each reach apply.
Implementations§
Source§impl Owner
impl Owner
Sourcepub fn start(s: Start) -> Result<Self, StartError>
pub fn start(s: Start) -> Result<Self, StartError>
Starts an owner from its startup values and its persisted layer, never from a runtime change (§2.12): revision 0, nothing pending.
§Errors
A StartError for a floor of 0, an apply_after not below the
floor, more than 16 groups, a name declared twice, bounds that cross,
a startup source other than file or default, or a layer naming a
parameter the schema does not declare, or a sensitive one in the
persisted layer.
Sourcepub fn whole_seconds(self) -> Self
pub fn whole_seconds(self) -> Self
The owner with every deadline and apply_at it states rounded up
to the next whole second, acted on at that instant: config.v2’s
times (its §2.8), which v2::Owner runs this owner under.
config.v1 keeps milliseconds.
Sourcepub fn restart(&self, instance: impl Into<String>) -> Self
pub fn restart(&self, instance: impl Into<String>) -> Self
The owner after a restart, as a new instance (§2.12): its startup values and persisted layer, revision 0, nothing pending, no last change, no key held. The persisted layer and the published events survive it.
Sourcepub fn next_due(&self) -> Option<Time>
pub fn next_due(&self) -> Option<Time>
The next instant Owner::due has something to do: the earliest
reach apply_at, or the deadline.
Sourcepub fn apply_at(&self) -> Option<Time>
pub fn apply_at(&self) -> Option<Time>
The apply_at of the last reach group to join the pending change
that has not applied yet, if one waits: None when the change is
applied, or when none is pending (config.v2 §2.9).
Sourcepub fn report_desired(&mut self, report: Option<DesiredReport>)
pub fn report_desired(&mut self, report: Option<DesiredReport>)
Sets the desired report the view and the status carry (§2.18).
Sourcepub fn desired(&self) -> Option<&DesiredReport>
pub fn desired(&self) -> Option<&DesiredReport>
The desired report the view and the status carry (§2.18).
Sourcepub fn published(&self, now: Time) -> Vec<Time>
pub fn published(&self, now: Time) -> Vec<Time>
The instants of the change events published within the last hour
at now, oldest first (§2.17): what the next instance starts from
(Start::events), so that the event’s rate, which a re-mint does
not reset (core §2.7), holds across a restart.
Sourcepub fn converge(&self, doc: &DesiredConfig) -> Converge
pub fn converge(&self, doc: &DesiredConfig) -> Converge
What converging doc asks next (§2.18): wait while a change is
pending or an act is in flight; the document refused whole
(check_desired); one set without a window on the first group,
in the bytewise order of the group names, whose values differ from
the running ones; or converged. Called again after each set, it
moves to the next group, since the one applied no longer differs.
Sourcepub fn facts(&self, now: Time) -> Facts<'_>
pub fn facts(&self, now: Time) -> Facts<'_>
What the validators read of the owner’s state at now.
Sourcepub fn startup(&self, group: &str, parameter: &str) -> Option<(Value, Source)>
pub fn startup(&self, group: &str, parameter: &str) -> Option<(Value, Source)>
A parameter’s startup value and its source (§2.12): the persisted
layer’s, else the startup file’s or the default. None for a
parameter that starts unknown, or that the schema does not declare.
Sourcepub fn baseline_document<'n>(
&self,
named: impl IntoIterator<Item = (&'n str, &'n str)>,
) -> DesiredConfig
pub fn baseline_document<'n>( &self, named: impl IntoIterator<Item = (&'n str, &'n str)>, ) -> DesiredConfig
The document a delete reverts the owner to, when desired.v1 feeds
it (desired.v1 §2.16, text 0.3): each parameter of named (the
ones the documents it acted on named) at its startup value, the
persisted layer’s, else the startup file’s or the default; one that
starts unknown is left out, and keeps its running value. Converged
as any document is (Owner::converge): one set without a window
per group whose running values differ, nothing for one that already
runs its startup values.
Sourcepub fn restart_plan(&self) -> Result<Vec<Restore>, (String, String)>
pub fn restart_plan(&self) -> Result<Vec<Restore>, (String, String)>
What a re-mint returns the device to first (§2.12, “A re-mint is a
restart”): each parameter whose running value is not its startup
value, unknown included, at its startup value (the persisted
layer’s, else the startup file’s or the default), in the schema’s
order. Empty when the device runs its startup values. Err names
the first parameter that runs a value but starts unknown, which
nothing returns it to. Read with nothing pending: a pending change
is cancelled first.
§Errors
(group, parameter) of a parameter with a running value and no
startup value.
Sourcepub fn view(&self) -> ConfigView
pub fn view(&self) -> ConfigView
The read-back (§2.3).
Sourcepub fn status(&self) -> ConfigStatus
pub fn status(&self) -> ConfigStatus
The compact status, the view’s projection (§2.19).
Sourcepub fn replays(&self, now: Time, group: &str, req: &SetRequest) -> bool
pub fn replays(&self, now: Time, group: &str, req: &SetRequest) -> bool
Whether a set of group with req would be answered now with the
first answer its idempotency key holds (§2.14): what Owner::set
replays, read without a change. A runtime that keeps the bytes it
sent then sends them again, the first answer’s as-of mark included
(core §5.1, “An answer sent again”).
Sourcepub fn holds_key(&self, now: Time, key: &str) -> bool
pub fn holds_key(&self, now: Time, key: &str) -> bool
Whether the owner holds a first answer for idempotency key key at
now (§2.14): within 300 s of it.
Sourcepub fn set(
&mut self,
now: Time,
group: &str,
req: &SetRequest,
call: &Call,
) -> Step
pub fn set( &mut self, now: Time, group: &str, req: &SetRequest, call: &Call, ) -> Step
A set (§2.5, §2.9): answered now, or an Act::Apply for a hot
group, whose reply comes with Owner::finish.
Sourcepub fn confirm(&mut self, now: Time, req: &ControlRequest, _call: &Call) -> Step
pub fn confirm(&mut self, now: Time, req: &ControlRequest, _call: &Call) -> Step
confirm (§2.10): always answered now.
Sourcepub fn extend(&mut self, now: Time, req: &ControlRequest, _call: &Call) -> Step
pub fn extend(&mut self, now: Time, req: &ControlRequest, _call: &Call) -> Step
extend (§2.10): always answered now; the deadline moves to now
plus the window, earlier or later.
Sourcepub fn cancel(&mut self, now: Time, req: &ControlRequest, _call: &Call) -> Step
pub fn cancel(&mut self, now: Time, req: &ControlRequest, _call: &Call) -> Step
cancel (§2.10): the undo now, an Act::Undo when something of
the change is applied, else answered now.
Sourcepub fn persist_plan(
&self,
now: Time,
req: &ControlRequest,
) -> Result<PersistPlan, Refusal>
pub fn persist_plan( &self, now: Time, req: &ControlRequest, ) -> Result<PersistPlan, Refusal>
Admits a persist (§2.13): the entries to write. Nothing changes
until Owner::persisted; a write that fails is the runtime’s
internal.
§Errors
The Refusal.
Sourcepub fn persisted(&mut self, plan: PersistPlan) -> Done
pub fn persisted(&mut self, plan: PersistPlan) -> Done
Commits a persist whose entries the runtime wrote (§2.13): a
parameter that runs the value persisted reads source: overlay,
unless an applied group of a pending change holds it, which keeps
its value and source and shows the persisted value as startup;
and a pending change’s value before it, when it is the value
persisted, restores at source: overlay (text 0.2, F-111). No
revision, no event.
Sourcepub fn due(&mut self, now: Time) -> Option<Step>
pub fn due(&mut self, now: Time) -> Option<Step>
The act owed at now, if any (§2.9, §2.11): the deadline’s undo,
or else the earliest reach apply whose apply_at has come. A change
with nothing applied ends at its deadline without an act. None
while an act is in flight, or when nothing is owed.
Sourcepub fn finish(&mut self, now: Time, result: DeviceResult) -> Step
pub fn finish(&mut self, now: Time, result: DeviceResult) -> Step
Reports the device’s result for the act in flight, and answers what
it owed: a set’s reply, a cancel’s, the events of a change it
ended, or a next act (the undo after a reach apply that failed).
Trait Implementations§
Auto Trait Implementations§
impl Forget for Owner
impl Freeze for Ownerwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<GroupDecl>: Freeze,
*const LeafNode<(String, String), (Value, Source)> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<((String, String), (Value, Source))>>: Freeze,
*const LeafNode<(String, String), Value> is !null: Freeze,
PhantomData<Box<((String, String), Value)>>: Freeze,
*const LeafNode<(String, String), Slot> is !null: Freeze,
PhantomData<Box<((String, String), Slot)>>: Freeze,
PhantomData<String>: Freeze,
*const LeafNode<(String, String), EditRec> is !null: Freeze,
PhantomData<Box<((String, String), EditRec)>>: Freeze,
PhantomData<Wait>: Freeze,
PhantomData<Held>: Freeze,
PhantomData<Time>: Freeze,
*const LeafNode<String, Value> is !null: Freeze,
PhantomData<Box<(String, Value)>>: Freeze,
*const LeafNode<String, Value> is !null: Freeze,
PhantomData<Box<(String, Value)>>: Freeze,
PhantomData<(String, String)>: Freeze,
impl Move for Owner
impl RefUnwindSafe for Owner
impl Send for Ownerwhere
RawVecInner: Send,
NodeRef<Owned, (String, String), (Value, Source), LeafOrInternal>: Send,
BoxRaw<((String, String), (Value, Source))>: Send,
NodeRef<Owned, (String, String), Value, LeafOrInternal>: Send,
BoxRaw<((String, String), Value)>: Send,
NodeRef<Owned, (String, String), Slot, LeafOrInternal>: Send,
BoxRaw<((String, String), Slot)>: Send,
NodeRef<Owned, (String, String), EditRec, LeafOrInternal>: Send,
BoxRaw<((String, String), EditRec)>: Send,
NodeRef<Owned, String, Value, LeafOrInternal>: Send,
BoxRaw<(String, Value)>: Send,
NodeRef<Owned, String, Value, LeafOrInternal>: Send,
BoxRaw<(String, Value)>: Send,
BoxRaw<ConfigView>: Send,
BoxRaw<ConfigStatus>: Send,
impl Sync for Ownerwhere
RawVecInner: Sync,
NodeRef<Owned, (String, String), (Value, Source), LeafOrInternal>: Sync,
BoxRaw<((String, String), (Value, Source))>: Sync,
NodeRef<Owned, (String, String), Value, LeafOrInternal>: Sync,
BoxRaw<((String, String), Value)>: Sync,
NodeRef<Owned, (String, String), Slot, LeafOrInternal>: Sync,
BoxRaw<((String, String), Slot)>: Sync,
NodeRef<Owned, (String, String), EditRec, LeafOrInternal>: Sync,
BoxRaw<((String, String), EditRec)>: Sync,
NodeRef<Owned, String, Value, LeafOrInternal>: Sync,
BoxRaw<(String, Value)>: Sync,
NodeRef<Owned, String, Value, LeafOrInternal>: Sync,
BoxRaw<(String, Value)>: Sync,
BoxRaw<ConfigView>: Sync,
BoxRaw<ConfigStatus>: Sync,
impl Unpin for Ownerwhere
*const u8 is !null: Unpin,
*const LeafNode<(String, String), (Value, Source)> is !null: Unpin,
Box<((String, String), (Value, Source))>: Unpin,
*const LeafNode<(String, String), Value> is !null: Unpin,
Box<((String, String), Value)>: Unpin,
*const LeafNode<(String, String), Slot> is !null: Unpin,
Box<((String, String), Slot)>: Unpin,
*const LeafNode<(String, String), EditRec> is !null: Unpin,
Box<((String, String), EditRec)>: Unpin,
*const LeafNode<String, Value> is !null: Unpin,
Box<(String, Value)>: Unpin,
*const LeafNode<String, Value> is !null: Unpin,
Box<(String, Value)>: Unpin,
Box<ConfigView>: Unpin,
Box<ConfigStatus>: Unpin,
impl UnsafeUnpin for Ownerwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<GroupDecl>: UnsafeUnpin,
*const LeafNode<(String, String), (Value, Source)> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<((String, String), (Value, Source))>>: UnsafeUnpin,
*const LeafNode<(String, String), Value> is !null: UnsafeUnpin,
PhantomData<Box<((String, String), Value)>>: UnsafeUnpin,
*const LeafNode<(String, String), Slot> is !null: UnsafeUnpin,
PhantomData<Box<((String, String), Slot)>>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const LeafNode<(String, String), EditRec> is !null: UnsafeUnpin,
PhantomData<Box<((String, String), EditRec)>>: UnsafeUnpin,
PhantomData<Wait>: UnsafeUnpin,
PhantomData<Held>: UnsafeUnpin,
PhantomData<Time>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
PhantomData<(String, String)>: UnsafeUnpin,
impl UnwindSafe for Ownerwhere
RawVecInner: UnwindSafe,
BTreeMap<(String, String), (Value, Source)>: UnwindSafe,
BTreeMap<(String, String), Value>: UnwindSafe,
BTreeMap<(String, String), Slot>: UnwindSafe,
BTreeMap<(String, String), EditRec>: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
BoxRaw<ConfigView>: UnwindSafe,
BoxRaw<ConfigStatus>: UnwindSafe,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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