Skip to main content

Owner

Struct Owner 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn schema(&self) -> &Schema

The schema.

Source

pub fn instance(&self) -> &str

The instance id.

Source

pub fn revision(&self) -> u64

The revision.

Source

pub fn in_flight(&self) -> bool

Whether an act is in flight.

Source

pub fn next_due(&self) -> Option<Time>

The next instant Owner::due has something to do: the earliest reach apply_at, or the deadline.

Source

pub fn deadline(&self) -> Option<Time>

The pending change’s deadline, if a change is pending.

Source

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).

Source

pub fn report_desired(&mut self, report: Option<DesiredReport>)

Sets the desired report the view and the status carry (§2.18).

Source

pub fn desired(&self) -> Option<&DesiredReport>

The desired report the view and the status carry (§2.18).

Source

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.

Source

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.

Source

pub fn facts(&self, now: Time) -> Facts<'_>

What the validators read of the owner’s state at now.

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.

Source

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.

Source

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.

Source

pub fn view(&self) -> ConfigView

The read-back (§2.3).

Source

pub fn status(&self) -> ConfigStatus

The compact status, the view’s projection (§2.19).

Source

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”).

Source

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.

Source

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.

Source

pub fn confirm(&mut self, now: Time, req: &ControlRequest, _call: &Call) -> Step

confirm (§2.10): always answered now.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Clone for Owner

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Owner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Owner

§

impl Freeze for Owner
where *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 Owner
where 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 Owner
where 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 Owner
where *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 Owner

§

impl UnwindSafe for Owner

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> AsNode<T> for T

Source§

fn as_node(&self) -> &T

Source§

impl<T> AsNodeMut<T> for T

Source§

fn as_node_mut(&mut self) -> &mut T

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.