pub struct ReadoutOptions { /* private fields */ }Expand description
Per-call readout options. Storage = small inline Vec<(String, OptionValue)>;
option counts are typically 0-3 so a hashmap is overkill.
SRD-63 §5.1 option grammar — every key=value pair the
body parser produces (other than the structural keys
lod / layout / color / style which have
dedicated paths) lands here.
Lookup is linear — fine at the option counts we expect. Two accessor families:
- Lenient (
get_str,get_int, …) — returnNonefor both “missing key” and “wrong type.” Right for readouts that fall back to a sensible default. - Strict (
try_get_str,try_get_int, …) — returnOk(None)on missing,Err(OptionTypeMismatch)on type mismatch. Right for readouts that should reject typo’d configurations rather than silently ignore them.
Implementations§
Source§impl ReadoutOptions
impl ReadoutOptions
Sourcepub fn set(&mut self, key: impl Into<String>, value: OptionValue)
pub fn set(&mut self, key: impl Into<String>, value: OptionValue)
Insert / overwrite. Last-one-wins on duplicate keys, matching the standard YAML / kv-list convention.
Sourcepub fn get(&self, key: &str) -> Option<&OptionValue>
pub fn get(&self, key: &str) -> Option<&OptionValue>
Borrow the value for key, if any.
Sourcepub fn get_str(&self, key: &str) -> Option<&str>
pub fn get_str(&self, key: &str) -> Option<&str>
Lenient: borrow as &str if the key holds a
string value. Returns None for missing key OR
wrong type. Use try_get_str
when the distinction matters.
Sourcepub fn get_float(&self, key: &str) -> Option<f64>
pub fn get_float(&self, key: &str) -> Option<f64>
Lenient: extract the float value, casting from
Int when needed.
Sourcepub fn try_get_str(&self, key: &str) -> Result<Option<&str>, OptionTypeMismatch>
pub fn try_get_str(&self, key: &str) -> Result<Option<&str>, OptionTypeMismatch>
Strict: Ok(None) on missing key, Ok(Some(...))
on string match, Err(...) when the key holds a
non-string value. Per feedback_never_ignore_silently:
callers that mean to reject typo’d options use this
instead of get_str.
Sourcepub fn try_get_int(&self, key: &str) -> Result<Option<i64>, OptionTypeMismatch>
pub fn try_get_int(&self, key: &str) -> Result<Option<i64>, OptionTypeMismatch>
Strict integer accessor. See try_get_str.
Sourcepub fn try_get_float(
&self,
key: &str,
) -> Result<Option<f64>, OptionTypeMismatch>
pub fn try_get_float( &self, key: &str, ) -> Result<Option<f64>, OptionTypeMismatch>
Strict float accessor. Accepts Int (cast to f64)
alongside Float; rejects everything else.
Sourcepub fn try_get_bool(
&self,
key: &str,
) -> Result<Option<bool>, OptionTypeMismatch>
pub fn try_get_bool( &self, key: &str, ) -> Result<Option<bool>, OptionTypeMismatch>
Strict bool accessor.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &OptionValue)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &OptionValue)>
Iterate every (key, value) pair.
Trait Implementations§
Source§impl Clone for ReadoutOptions
impl Clone for ReadoutOptions
Source§impl Debug for ReadoutOptions
impl Debug for ReadoutOptions
Auto Trait Implementations§
impl Freeze for ReadoutOptions
impl RefUnwindSafe for ReadoutOptions
impl Send for ReadoutOptions
impl Sync for ReadoutOptions
impl Unpin for ReadoutOptions
impl UnsafeUnpin for ReadoutOptions
impl UnwindSafe for ReadoutOptions
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> 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 more