#[non_exhaustive]pub enum PreferenceValue {
#[non_exhaustive] Timezone {
value: String,
},
#[non_exhaustive] DateGrain {
grain: DateGrain,
},
#[non_exhaustive] OutputStyle {
style: OutputStyle,
},
#[non_exhaustive] DefaultProfile {
name: String,
},
}Expand description
A bounded user preference. Closed enums and shape-validated strings only; no free-text variant exists by design.
Deserialize is hand-rolled, not derived: the string-carrying variants run
their shape validators on deserialization too, so a {"kind":"timezone", "value":"SELECT ..."} row is refused by the type, not only by the store’s
admission gate. A derived Deserialize would populate the field directly
and bypass the constructors — exactly the “validated constructor beside a
publicly-constructible variant” the security standard warns about, and the
spec’s “make it unrepresentable, not filtered” rule.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
#[non_exhaustive]Timezone
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]DateGrain
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]OutputStyle
Fields
This variant is marked as non-exhaustive
style: OutputStyle#[non_exhaustive]DefaultProfile
Implementations§
Source§impl PreferenceValue
impl PreferenceValue
Sourcepub fn kind(&self) -> &'static str
pub fn kind(&self) -> &'static str
The stable discriminator persisted as preference_kind, and used as
part of the store’s primary key.
Sourcepub fn required_scope(&self) -> ScopeRequirement
pub fn required_scope(&self) -> ScopeRequirement
The scope this value must be stored under. A value set at the wrong scope is a typed error, never a silent coercion.
Sourcepub fn matches_scope(&self, scope: &PreferenceScope) -> bool
pub fn matches_scope(&self, scope: &PreferenceScope) -> bool
True if scope is the one this value requires. Convenience over
required_scope().matches(scope).
Sourcepub fn timezone(value: impl AsRef<str>) -> Result<Self, ContractError>
pub fn timezone(value: impl AsRef<str>) -> Result<Self, ContractError>
Construct a timezone preference. Validation is shape only: non-empty,
≤64 chars, ASCII alphanumeric plus /, _, + and -. A wrong-but-
well-shaped timezone is a user error they can see and fix; bundling an
IANA list to validate membership would be a maintenance burden that goes
stale. A fictional-but-well-shaped name is accepted on purpose.
pub fn date_grain(grain: DateGrain) -> Self
pub fn output_style(style: OutputStyle) -> Self
Sourcepub fn default_profile(name: impl AsRef<str>) -> Result<Self, ContractError>
pub fn default_profile(name: impl AsRef<str>) -> Result<Self, ContractError>
Construct a default-profile preference from a profile name. The name is
validated by the same shape rules as a database object name: non-empty,
bounded, no control characters. A name is not an identity — it never
reaches the database bytes as p-…, and it is resolved against the live
connections.toml at use time, not stored as a pointer to a profile.
Sourcepub fn timezone_value(&self) -> Option<&str>
pub fn timezone_value(&self) -> Option<&str>
The persisted string for a Timezone value, or None for other kinds.
Used only by tests that assert a round-tripped value byte-for-byte.
Sourcepub fn default_profile_name(&self) -> Option<&str>
pub fn default_profile_name(&self) -> Option<&str>
The persisted name for a DefaultProfile value, or None for other kinds.
Trait Implementations§
Source§impl Clone for PreferenceValue
impl Clone for PreferenceValue
Source§fn clone(&self) -> PreferenceValue
fn clone(&self) -> PreferenceValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more