pub struct Switch {
pub device: BTreeMap<String, Device>,
pub other: Table,
}Expand description
The switch’s file: a table per device.
Fields§
§device: BTreeMap<String, Device>§other: TableWhat a later version writes here, kept as it is.
Implementations§
Source§impl Switch
impl Switch
pub fn default_path() -> PathBuf
Sourcepub fn read(path: &Path) -> Result<Switch, String>
pub fn read(path: &Path) -> Result<Switch, String>
The file as it is; none there is no press anywhere yet. One that does not read is an error: never taken for no device at all.
Sourcepub fn load(path: &Path) -> Switch
pub fn load(path: &Path) -> Switch
For a question (the status line, an apply): what cannot be read is no press.
Sourcepub fn latest(&self) -> Option<Press>
pub fn latest(&self) -> Option<Press>
The latest press anywhere wins; one that did not know of a quieter
press made on another device less than MARGIN_MS before it gives way
to it: the quietest of those (Do not disturb, then As usual, then
Reachable), as “on” won before there were three states.
Sourcepub fn counted(&self, here: &str, counts: &dyn Fn(&str) -> bool) -> Switch
pub fn counted(&self, here: &str, counts: &dyn Fn(&str) -> bool) -> Switch
The switch as this device reads it, the devices that count (counts,
by id; this device’s always) as they are; a device gone from the
sharing (it left, you forgot it, another replaces it) read as an As
usual at its last press, and its Expecting a call as “Screen calls
again” at its own, nothing more: it still ends what came
before it, so that a do-not-disturb it ended never comes back (review
of part 3, F1), and it holds off, releases and brings back nothing,
nor is it a device that follows (no table time).
Sourcepub fn release_stamps(&self) -> Vec<(String, i64)>
pub fn release_stamps(&self) -> Vec<(String, i64)>
What the phone is asked to let through, held before then, by the device that asks (milliseconds, that device’s hybrid clock): each device’s “Let what your phone holds through”, and the Reachable press that is the press that holds. The phone applies each device’s stamps once, apart: a stamp from one device, however far ahead, never stands in the way of another’s (review of part 3, F3).
Sourcepub fn next_stamp(&self, now_ms: i64) -> i64
pub fn next_stamp(&self, now_ms: i64) -> i64
The stamp of a press or a release made here at now_ms: after every
press known within CLOCK_AHEAD_MS of this clock and every release
known within RELEASE_FOLLOWED_MS (a hybrid clock): a release from a
clock far ahead never drags the presses along, which would then hold
off for hours what begins meanwhile (review of part 3, F3 and R-3); a
press a day ahead or more (a clock gone wrong, a garbled table,
i64::MAX) is not followed either. Never overflows.
Sourcepub fn release(&mut self, here: &str, now_ms: i64) -> i64
pub fn release(&mut self, here: &str, now_ms: i64) -> i64
“Let what your phone holds through”, pressed here: a stamp after every press and release known (a hybrid clock). Returns it.
Sourcepub fn latest_known(&self, except: Option<&str>) -> i64
pub fn latest_known(&self, except: Option<&str>) -> i64
The latest press known here, of any device but except (milliseconds).
Sourcepub fn press(&mut self, here: &str, on: bool, until: i64, now_ms: i64) -> i64
pub fn press(&mut self, here: &str, on: bool, until: i64, now_ms: i64) -> i64
A press here, stamped after every press known (a hybrid clock): until
in milliseconds, 0 for none. Returns its stamp.
Sourcepub fn press_via(
&mut self,
here: &str,
on: bool,
until: i64,
now_ms: i64,
via: &str,
) -> i64
pub fn press_via( &mut self, here: &str, on: bool, until: i64, now_ms: i64, via: &str, ) -> i64
A press here, as press, saying where it came from (VIA_SYSTEM: this
device’s own do-not-disturb, heard as it changed; “”: the switch).
Sourcepub fn press_state(
&mut self,
here: &str,
state: State,
until: i64,
open: bool,
now_ms: i64,
via: &str,
) -> i64
pub fn press_state( &mut self, here: &str, state: State, until: i64, open: bool, now_ms: i64, via: &str, ) -> i64
A press of one of the three states here, as press_via: until its
end (milliseconds; 0 none, never for As usual); open for Reachable
“until you turn it off”, until then its latest end. A Reachable press
writes on = false: an older Sioul reads do-not-disturb off.
Source§impl Switch
impl Switch
Sourcepub fn as_of(self, now_ms: i64) -> Switch
pub fn as_of(self, now_ms: i64) -> Switch
The switch as read at now_ms on this device: a press stamped more
than CLOCK_AHEAD_MS ahead of this clock (a garbled stamp, a clock a
year ahead) reads as not pressed yet, so that it never wins for ever
(review of part 3, R-8); its Expecting a call too.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Switch
impl<'de> Deserialize<'de> for Switch
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 StructuralPartialEq for Switch
Auto Trait Implementations§
impl Freeze for Switch
impl RefUnwindSafe for Switch
impl Send for Switch
impl Sync for Switch
impl Unpin for Switch
impl UnsafeUnpin for Switch
impl UnwindSafe for Switch
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> Conv for T
impl<T> Conv for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§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.§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.§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.§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.§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.§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.§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.§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.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§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 more§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 more§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
§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
§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.§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.§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.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§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 more§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 more§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 more§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 more§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 more§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 more§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.§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.§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.§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.§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.§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.§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.