Struct OptionOverride
pub struct OptionOverride {
pub option_type_id: TypeId,
pub value: Arc<dyn Any + Send + Sync>,
pub priority: OverridePriority,
}Expand description
One option-value override from a single layer producer (a mode, a buffer-local set, a modal-state hook).
Identity is the option_type_id — the TypeId of the
declaration type (e.g. TypeId::of::<Tabstop>()). The
resolver looks up the option by this id; the typed downcast
against the option’s Value is performed when emitting the
resolved cache.
Fields§
§option_type_id: TypeIdTypeId of the OptionDecl type this override targets.
OptionDecl lives in lattice-config; we don’t have
access to the trait at this layer, so we identify by
TypeId and trust the macro / consumer to construct
type-correctly.
value: Arc<dyn Any + Send + Sync>The override value, type-erased. Downcast at resolution
time to the declaration’s Value type.
priority: OverridePriorityTie-break priority. See OverridePriority.
Implementations§
§impl OptionOverride
impl OptionOverride
pub fn new<V>(option_type_id: TypeId, value: V) -> OptionOverride
pub fn new<V>(option_type_id: TypeId, value: V) -> OptionOverride
Erased constructor. The caller is responsible for
supplying a value of the type matching the declaration’s
Value – this contract is enforced by
lattice-config’s overrides! macro at compile time
(it generates a typed let-binding before the call). For
runtime / plugin construction, the caller is responsible
for honouring the contract.
pub fn with_priority<V>(
option_type_id: TypeId,
value: V,
priority: OverridePriority,
) -> OptionOverride
pub fn with_priority<V>( option_type_id: TypeId, value: V, priority: OverridePriority, ) -> OptionOverride
Same as Self::new but with explicit priority.
pub fn at_priority(self, priority: OverridePriority) -> OptionOverride
pub fn at_priority(self, priority: OverridePriority) -> OptionOverride
Promote self to a higher priority. Used by the
overrides! macro’s priority-attribute branch.
pub fn downcast_value<V>(&self) -> Option<&V>where
V: 'static,
pub fn downcast_value<V>(&self) -> Option<&V>where
V: 'static,
Attempt to downcast the value to the requested type.
Returns None if the stored value doesn’t match V.
Trait Implementations§
§impl Clone for OptionOverride
impl Clone for OptionOverride
§fn clone(&self) -> OptionOverride
fn clone(&self) -> OptionOverride
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more