pub struct OptionsGenerator {
pub registry: Arc<ConfigRegistry>,
}Expand description
Completion source for :set — option names, and name=value pairs
for options whose type enumerates its values.
Stateless beyond the shared registry handle: every
[CandidateGenerator::generate] call re-walks the registry, so
options registered later (a plugin’s, a renderer’s) appear without
rebuilding the generator. Candidates are unfiltered; the
lattice-completion matcher narrows them against the prefix.
§Examples
use std::sync::Arc;
use lattice_config::{ConfigRegistry, OptionsGenerator};
let registry = Arc::new(ConfigRegistry::new());
registry.init_from_linkme();
let generator = OptionsGenerator::new(Arc::clone(®istry));
assert!(Arc::ptr_eq(&generator.registry, ®istry));Fields§
§registry: Arc<ConfigRegistry>The registry walked on each generate call. Shared, not
snapshotted: registrations after construction are visible.
Implementations§
Source§impl OptionsGenerator
impl OptionsGenerator
Sourcepub fn new(registry: Arc<ConfigRegistry>) -> Self
pub fn new(registry: Arc<ConfigRegistry>) -> Self
A generator over registry.
Trait Implementations§
Source§impl CandidateGenerator for OptionsGenerator
impl CandidateGenerator for OptionsGenerator
fn generate(&self, ctx: &GenerateContext<'_>) -> Vec<RawCandidate>
§fn cache_key(&self, _ctx: &GenerateContext<'_>) -> Option<CacheKey>
fn cache_key(&self, _ctx: &GenerateContext<'_>) -> Option<CacheKey>
Optional cache key. When two contexts produce the same
Some(key), the pipeline serves the second from cache. The
query (prefix) is implicitly part of the key only if the
generator includes it – many generators key on a registry
version (cache covers all queries until the registry
changes) and let the matcher do the per-query filtering.Auto Trait Implementations§
impl Freeze for OptionsGenerator
impl RefUnwindSafe for OptionsGenerator
impl Send for OptionsGenerator
impl Sync for OptionsGenerator
impl Unpin for OptionsGenerator
impl UnsafeUnpin for OptionsGenerator
impl UnwindSafe for OptionsGenerator
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
Mutably borrows from an owned value. Read more