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§
Source§impl OptionOverride
impl OptionOverride
Sourcepub fn new<V: Clone + Send + Sync + 'static>(
option_type_id: TypeId,
value: V,
) -> Self
pub fn new<V: Clone + Send + Sync + 'static>( option_type_id: TypeId, value: V, ) -> Self
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.
Sourcepub fn with_priority<V: Clone + Send + Sync + 'static>(
option_type_id: TypeId,
value: V,
priority: OverridePriority,
) -> Self
pub fn with_priority<V: Clone + Send + Sync + 'static>( option_type_id: TypeId, value: V, priority: OverridePriority, ) -> Self
Same as Self::new but with explicit priority.
Sourcepub fn at_priority(self, priority: OverridePriority) -> Self
pub fn at_priority(self, priority: OverridePriority) -> Self
Promote self to a higher priority. Used by the
overrides! macro’s priority-attribute branch.
Sourcepub fn downcast_value<V: 'static>(&self) -> Option<&V>
pub fn downcast_value<V: 'static>(&self) -> Option<&V>
Attempt to downcast the value to the requested type.
Returns None if the stored value doesn’t match V.
Trait Implementations§
Source§impl Clone for OptionOverride
impl Clone for OptionOverride
Source§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