#[non_exhaustive]pub struct AreaSettings {
pub partition: PartitionId,
pub quiet_time: Option<Change<Option<QuietHours>>>,
pub daily_spending_limit: Option<Change<Option<u64>>>,
pub mode: Option<Change<PartitionMode>>,
pub start: Option<AreaStart>,
pub earlier_quiet_time: Vec<Change<Option<QuietHours>>>,
}Expand description
The settings a person changed for one area while the kernel ran (spec 3.3 §8.1 “Areas”,
§10 K3). Each one set replaces, for the area, the value the kernel and the area’s
partition record started with, while the area still starts with that value
(start); one never set leaves the start value in force.
§Example
use adk_kernel::control::{AreaSettings, Change};
use adk_kernel::{PartitionMode, QuietHours};
let now = chrono::Utc::now();
let settings = AreaSettings::new("work")
.with_quiet_time(Change::new(Some("22:00-07:00".parse::<QuietHours>().unwrap()), "ana", now))
.with_mode(Change::new(PartitionMode::Ask, "ana", now));
let wire = serde_json::to_value(&settings).unwrap();
assert_eq!(wire["quietTime"]["value"]["start"], "22:00");
assert_eq!(wire["mode"]["value"], "ask");
assert!(wire.get("dailySpendingLimit").is_none());Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.partition: PartitionIdThe area: a partition, default on a kernel without partitions.
quiet_time: Option<Change<Option<QuietHours>>>Quiet time; value: None is no quiet time.
daily_spending_limit: Option<Change<Option<u64>>>The daily spending limit in micro-USD; value: None is no limit.
mode: Option<Change<PartitionMode>>How much the area’s agents act alone.
start: Option<AreaStart>What the area started with when a setting was last changed; None on a record
written without it, whose changes hold whatever the area starts with.
earlier_quiet_time: Vec<Change<Option<QuietHours>>>The quiet times earlier changes set, oldest first, at most
QUIET_TIME_HISTORY: past work is judged against the
quiet time in force when it started.
Implementations§
Source§impl AreaSettings
impl AreaSettings
Sourcepub const QUIET_TIME_HISTORY: usize = 32
pub const QUIET_TIME_HISTORY: usize = 32
How many earlier quiet times a record keeps.
Sourcepub fn new(partition: impl Into<PartitionId>) -> Self
pub fn new(partition: impl Into<PartitionId>) -> Self
No changed setting for partition.
Sourcepub fn with_start(self, start: AreaStart) -> Self
pub fn with_start(self, start: AreaStart) -> Self
Records that the area started with start.
Sourcepub fn quiet_time_over(
&self,
start: &[QuietHours],
) -> Option<&Change<Option<QuietHours>>>
pub fn quiet_time_over( &self, start: &[QuietHours], ) -> Option<&Change<Option<QuietHours>>>
The changed quiet time, when the area still starts with the windows it replaced.
Sourcepub fn daily_spending_limit_over(
&self,
start: Option<u64>,
) -> Option<&Change<Option<u64>>>
pub fn daily_spending_limit_over( &self, start: Option<u64>, ) -> Option<&Change<Option<u64>>>
The changed daily spending limit, when the area still starts with the cap it replaced.
Sourcepub fn mode_over(
&self,
start: Option<PartitionMode>,
) -> Option<&Change<PartitionMode>>
pub fn mode_over( &self, start: Option<PartitionMode>, ) -> Option<&Change<PartitionMode>>
The changed mode, when the area’s agents still start in the mode it replaced.
Sourcepub fn settle(&mut self, start: &AreaStart)
pub fn settle(&mut self, start: &AreaStart)
Drops every change whose start value start has replaced since, then records
start (spec 3.3 §10 K3): call it before changing a setting.
Sourcepub fn change_quiet_time(&mut self, change: Change<Option<QuietHours>>)
pub fn change_quiet_time(&mut self, change: Change<Option<QuietHours>>)
Sets the changed quiet time, keeping the one it replaces among the earlier ones.
Sourcepub fn quiet_time_at(
&self,
at: DateTime<Utc>,
) -> Option<&Change<Option<QuietHours>>>
pub fn quiet_time_at( &self, at: DateTime<Utc>, ) -> Option<&Change<Option<QuietHours>>>
The person’s quiet time in force at at, as the area’s changes record it: the
newest change made at or before at, to the millisecond the ledger stamps its rows
with, or None before the first one, when the start windows held.
Sourcepub fn with_quiet_time(self, change: Change<Option<QuietHours>>) -> Self
pub fn with_quiet_time(self, change: Change<Option<QuietHours>>) -> Self
Sets the changed quiet time.
Sourcepub fn with_daily_spending_limit(self, change: Change<Option<u64>>) -> Self
pub fn with_daily_spending_limit(self, change: Change<Option<u64>>) -> Self
Sets the changed daily spending limit.
Sourcepub fn with_mode(self, change: Change<PartitionMode>) -> Self
pub fn with_mode(self, change: Change<PartitionMode>) -> Self
Sets the changed mode.
Trait Implementations§
Source§impl Clone for AreaSettings
impl Clone for AreaSettings
Source§impl Debug for AreaSettings
impl Debug for AreaSettings
Source§impl<'de> Deserialize<'de> for AreaSettings
impl<'de> Deserialize<'de> for AreaSettings
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>,
impl Eq for AreaSettings
Source§impl PartialEq for AreaSettings
impl PartialEq for AreaSettings
Source§impl Serialize for AreaSettings
impl Serialize for AreaSettings
impl StructuralPartialEq for AreaSettings
Auto Trait Implementations§
impl Forget for AreaSettings
impl Freeze for AreaSettingswhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
NonZero<i32>: Freeze,
Utc: Freeze,
PhantomData<QuietHours>: Freeze,
PhantomData<Change<Option<QuietHours>>>: Freeze,
impl Move for AreaSettings
impl RefUnwindSafe for AreaSettings
impl Send for AreaSettings
impl Sync for AreaSettings
impl Unpin for AreaSettings
impl UnsafeUnpin for AreaSettingswhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
NonZeroI32Inner: UnsafeUnpin,
Utc: UnsafeUnpin,
PhantomData<QuietHours>: UnsafeUnpin,
PhantomData<Change<Option<QuietHours>>>: UnsafeUnpin,
impl UnwindSafe for AreaSettings
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.