pub struct CompsysCache { /* private fields */ }Expand description
SQLite cache for completion system
Implementations§
Source§impl CompsysCache
impl CompsysCache
Sourcepub fn conn(&self) -> &Connection
pub fn conn(&self) -> &Connection
Access the underlying SQLite connection (for dbview etc.)
Sourcepub fn count_table(&self, table: &str) -> Result<usize>
pub fn count_table(&self, table: &str) -> Result<usize>
Count rows in a table.
Sourcepub fn count_table_where(&self, table: &str, condition: &str) -> Result<usize>
pub fn count_table_where(&self, table: &str, condition: &str) -> Result<usize>
Count rows matching a WHERE clause.
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open or create cache database with maximum performance settings
Sourcepub fn add_autoload(
&self,
name: &str,
source: &str,
offset: i64,
size: i64,
) -> Result<()>
pub fn add_autoload( &self, name: &str, source: &str, offset: i64, size: i64, ) -> Result<()>
Register an autoload stub (without body)
Sourcepub fn add_autoload_with_body(
&self,
name: &str,
source: &str,
body: &str,
) -> Result<()>
pub fn add_autoload_with_body( &self, name: &str, source: &str, body: &str, ) -> Result<()>
Register an autoload with full function body (for instant loading)
Sourcepub fn add_autoloads_bulk(
&mut self,
autoloads: &[(String, String, i64, i64)],
) -> Result<()>
pub fn add_autoloads_bulk( &mut self, autoloads: &[(String, String, i64, i64)], ) -> Result<()>
Bulk insert autoloads (much faster)
Sourcepub fn add_autoloads_with_bodies_bulk(
&mut self,
autoloads: &[(String, String, String)],
) -> Result<()>
pub fn add_autoloads_with_bodies_bulk( &mut self, autoloads: &[(String, String, String)], ) -> Result<()>
Bulk insert autoloads with bodies (for compinit to cache function definitions)
Sourcepub fn get_autoload(&self, name: &str) -> Result<Option<AutoloadStub>>
pub fn get_autoload(&self, name: &str) -> Result<Option<AutoloadStub>>
Lookup autoload by name
Sourcepub fn get_autoload_body(&self, name: &str) -> Result<Option<String>>
pub fn get_autoload_body(&self, name: &str) -> Result<Option<String>>
Get function body directly (fast path for autoload -Xz)
Sourcepub fn count_autoloads_with_body(&self) -> Result<usize>
pub fn count_autoloads_with_body(&self) -> Result<usize>
Count autoloads with a non-NULL body. Replaces the legacy
count_autoloads_missing_bytecode — bytecode coverage is now derived
by subtracting the rkyv shard’s cached_names set from this count
(caller-side, see the autoload_cache module in the zsh / zshrs library crate).
Sourcepub fn get_autoload_bodies_excluding(
&self,
exclude: &HashSet<String>,
limit: usize,
) -> Result<Vec<(String, String)>>
pub fn get_autoload_bodies_excluding( &self, exclude: &HashSet<String>, limit: usize, ) -> Result<Vec<(String, String)>>
Get a batch of (name, body) pairs for autoloads with a non-NULL
body, excluding any whose name is in exclude (e.g. names already
present in the rkyv autoload-bytecode shard). Used by compinit’s
background backfill: SQLite supplies the source bodies, the caller
parses+compiles, then writes results to the rkyv shard.
Returns up to limit entries; caller iterates until the empty vec
or counts what was returned.
Sourcepub fn get_autoload_body_or_zwc(&self, name: &str) -> Option<String>
pub fn get_autoload_body_or_zwc(&self, name: &str) -> Option<String>
Get function body with ZWC fallback
- If body column has content, return it (fast path)
- If body is NULL but source/offset/size exist, read from ZWC file
- Returns None if function not found or ZWC read fails
Sourcepub fn autoload_count(&self) -> Result<i64>
pub fn autoload_count(&self) -> Result<i64>
Count autoloads
Sourcepub fn list_autoloads(&self, limit: usize) -> Result<Vec<String>>
pub fn list_autoloads(&self, limit: usize) -> Result<Vec<String>>
List all autoload names (for debugging)
Sourcepub fn list_autoload_names(&self) -> Result<Vec<String>>
pub fn list_autoload_names(&self) -> Result<Vec<String>>
List all autoload names (no limit)
Sourcepub fn set_zstyle(
&self,
pattern: &str,
style: &str,
values: &[String],
eval: bool,
) -> Result<()>
pub fn set_zstyle( &self, pattern: &str, style: &str, values: &[String], eval: bool, ) -> Result<()>
Set a zstyle
Sourcepub fn set_zstyles_bulk(
&mut self,
styles: &[(String, String, Vec<String>, bool)],
) -> Result<()>
pub fn set_zstyles_bulk( &mut self, styles: &[(String, String, Vec<String>, bool)], ) -> Result<()>
Bulk insert zstyles
Sourcepub fn delete_zstyle(&self, pattern: &str, style: Option<&str>) -> Result<usize>
pub fn delete_zstyle(&self, pattern: &str, style: Option<&str>) -> Result<usize>
Delete a zstyle
Sourcepub fn lookup_zstyle(
&self,
context: &str,
style: &str,
) -> Result<Option<ZStyleEntry>>
pub fn lookup_zstyle( &self, context: &str, style: &str, ) -> Result<Option<ZStyleEntry>>
Lookup zstyle - returns all matching patterns sorted by specificity
Sourcepub fn list_zstyles(&self) -> Result<Vec<(String, String, Vec<String>, bool)>>
pub fn list_zstyles(&self) -> Result<Vec<(String, String, Vec<String>, bool)>>
List all zstyles (for zstyle -L)
Sourcepub fn zstyle_count(&self) -> Result<i64>
pub fn zstyle_count(&self) -> Result<i64>
Count zstyles
Sourcepub fn set_comp(&self, command: &str, function: &str) -> Result<()>
pub fn set_comp(&self, command: &str, function: &str) -> Result<()>
Register a completion function for a command
Sourcepub fn set_comps_bulk(&mut self, comps: &[(String, String)]) -> Result<()>
pub fn set_comps_bulk(&mut self, comps: &[(String, String)]) -> Result<()>
Bulk insert comps + populate FTS5 index
Sourcepub fn comps_prefix_fts(&self, prefix: &str) -> Result<Vec<(String, String)>>
pub fn comps_prefix_fts(&self, prefix: &str) -> Result<Vec<(String, String)>>
Fast prefix search using FTS5 (O(log n) vs O(n) for LIKE)
Sourcepub fn comps_prefix(&self, prefix: &str) -> Result<Vec<(String, String)>>
pub fn comps_prefix(&self, prefix: &str) -> Result<Vec<(String, String)>>
Fast prefix search (LIKE with index scan, ORDER BY is free on indexed column)
Sourcepub fn get_comp(&self, command: &str) -> Result<Option<String>>
pub fn get_comp(&self, command: &str) -> Result<Option<String>>
Lookup completion function for command
Sourcepub fn get_all_comps(&self) -> Result<HashMap<String, String>>
pub fn get_all_comps(&self) -> Result<HashMap<String, String>>
Get all comps as HashMap (for compatibility)
Sourcepub fn comp_count(&self) -> Result<i64>
pub fn comp_count(&self) -> Result<i64>
Count comps
Sourcepub fn delete_comp(&self, command: &str) -> Result<usize>
pub fn delete_comp(&self, command: &str) -> Result<usize>
Delete a completion registration
Sourcepub fn set_patcomp(&self, pattern: &str, function: &str) -> Result<()>
pub fn set_patcomp(&self, pattern: &str, function: &str) -> Result<()>
Register a pattern completion
Sourcepub fn find_patcomp(&self, command: &str) -> Result<Option<String>>
pub fn find_patcomp(&self, command: &str) -> Result<Option<String>>
Find matching pattern completion
Sourcepub fn set_keycomp(&self, key: &str, function: &str) -> Result<()>
pub fn set_keycomp(&self, key: &str, function: &str) -> Result<()>
Register a key completion (for -K)
Sourcepub fn cache_results(
&self,
context: &str,
data: &[u8],
mtime: i64,
) -> Result<()>
pub fn cache_results( &self, context: &str, data: &[u8], mtime: i64, ) -> Result<()>
Cache completion results
Sourcepub fn get_cached(&self, context: &str, max_age: i64) -> Result<Option<Vec<u8>>>
pub fn get_cached(&self, context: &str, max_age: i64) -> Result<Option<Vec<u8>>>
Get cached results if not stale
Sourcepub fn clear_stale_cache(&self, max_age: i64) -> Result<usize>
pub fn clear_stale_cache(&self, max_age: i64) -> Result<usize>
Clear old cache entries
Sourcepub fn clear_cache(&self) -> Result<()>
pub fn clear_cache(&self) -> Result<()>
Clear all cache
Sourcepub fn stats(&self) -> Result<CacheStats>
pub fn stats(&self) -> Result<CacheStats>
Get database stats
Source§impl CompsysCache
impl CompsysCache
Sourcepub fn comps_count(&self) -> Result<i64>
pub fn comps_count(&self) -> Result<i64>
Get count of _comps entries (for $#_comps)
Sourcepub fn comps_keys(&self) -> Result<Vec<String>>
pub fn comps_keys(&self) -> Result<Vec<String>>
Get all _comps keys (for ${(k)_comps}) - ORDER BY is free on PRIMARY KEY
Sourcepub fn comps_values(&self) -> Result<Vec<String>>
pub fn comps_values(&self) -> Result<Vec<String>>
Get all _comps values (for ${(v)_comps})
Sourcepub fn comps_kv(&self) -> Result<Vec<(String, String)>>
pub fn comps_kv(&self) -> Result<Vec<(String, String)>>
Get _comps as key-value pairs (for ${(kv)_comps})
Sourcepub fn patcomps_count(&self) -> Result<i64>
pub fn patcomps_count(&self) -> Result<i64>
Get count of _patcomps
Sourcepub fn patcomps_keys(&self) -> Result<Vec<String>>
pub fn patcomps_keys(&self) -> Result<Vec<String>>
Get all _patcomps keys
Sourcepub fn services_count(&self) -> Result<i64>
pub fn services_count(&self) -> Result<i64>
Get count of _services
Sourcepub fn services_keys(&self) -> Result<Vec<String>>
pub fn services_keys(&self) -> Result<Vec<String>>
Get all _services keys
Sourcepub fn set_services_bulk(&mut self, services: &[(String, String)]) -> Result<()>
pub fn set_services_bulk(&mut self, services: &[(String, String)]) -> Result<()>
Bulk insert services
Sourcepub fn compautos_count(&self) -> Result<i64>
pub fn compautos_count(&self) -> Result<i64>
Get count of autoloaded functions
Sourcepub fn compautos_keys(&self) -> Result<Vec<String>>
pub fn compautos_keys(&self) -> Result<Vec<String>>
Get all autoload names (for ${(k)_compautos})
Sourcepub fn has_executables(&self) -> Result<bool>
pub fn has_executables(&self) -> Result<bool>
Check if executables cache is populated
Sourcepub fn set_executables_bulk(
&mut self,
executables: &[(String, String)],
) -> Result<()>
pub fn set_executables_bulk( &mut self, executables: &[(String, String)], ) -> Result<()>
Store executables in bulk + populate FTS5 index
Sourcepub fn get_executable_names(&self) -> Result<HashSet<String>>
pub fn get_executable_names(&self) -> Result<HashSet<String>>
Get all executable names (fast lookup set)
Sourcepub fn has_executable(&self, name: &str) -> Result<bool>
pub fn has_executable(&self, name: &str) -> Result<bool>
Check if an executable exists in cache (O(1) lookup)
Sourcepub fn get_executable_path(&self, name: &str) -> Result<Option<String>>
pub fn get_executable_path(&self, name: &str) -> Result<Option<String>>
Get executable path by name (direct key lookup)
Sourcepub fn get_executables_prefix_fts(
&self,
prefix: &str,
) -> Result<Vec<(String, String)>>
pub fn get_executables_prefix_fts( &self, prefix: &str, ) -> Result<Vec<(String, String)>>
Fast prefix search using FTS5
Sourcepub fn get_executables_prefix(
&self,
prefix: &str,
) -> Result<Vec<(String, String)>>
pub fn get_executables_prefix( &self, prefix: &str, ) -> Result<Vec<(String, String)>>
Get executables matching prefix (LIKE with index, ORDER BY free on PRIMARY KEY)
Sourcepub fn executables_count(&self) -> Result<i64>
pub fn executables_count(&self) -> Result<i64>
Count executables
Sourcepub fn has_named_dirs(&self) -> Result<bool>
pub fn has_named_dirs(&self) -> Result<bool>
Check if named_dirs cache is populated
Sourcepub fn set_named_dirs_bulk(&mut self, dirs: &[(String, String)]) -> Result<()>
pub fn set_named_dirs_bulk(&mut self, dirs: &[(String, String)]) -> Result<()>
Store named directories in bulk (clears existing)
Sourcepub fn get_named_dirs(&self) -> Result<Vec<(String, String)>>
pub fn get_named_dirs(&self) -> Result<Vec<(String, String)>>
Get all named directories (ORDER BY free on PRIMARY KEY)
Sourcepub fn get_named_dirs_prefix(
&self,
prefix: &str,
) -> Result<Vec<(String, String)>>
pub fn get_named_dirs_prefix( &self, prefix: &str, ) -> Result<Vec<(String, String)>>
Get named directories matching prefix
Sourcepub fn named_dirs_count(&self) -> Result<i64>
pub fn named_dirs_count(&self) -> Result<i64>
Count named directories
Sourcepub fn has_shell_functions(&self) -> Result<bool>
pub fn has_shell_functions(&self) -> Result<bool>
Check if shell_functions cache is populated
Sourcepub fn set_shell_functions_bulk(
&mut self,
funcs: &[(String, String)],
) -> Result<()>
pub fn set_shell_functions_bulk( &mut self, funcs: &[(String, String)], ) -> Result<()>
Store shell functions in bulk + populate FTS5 index
Sourcepub fn get_shell_function_names(&self) -> Result<Vec<String>>
pub fn get_shell_function_names(&self) -> Result<Vec<String>>
Get all shell function names (ORDER BY free on PRIMARY KEY)
Sourcepub fn get_shell_functions(&self) -> Result<Vec<(String, String)>>
pub fn get_shell_functions(&self) -> Result<Vec<(String, String)>>
Get shell functions with source paths
Sourcepub fn get_shell_functions_prefix_fts(
&self,
prefix: &str,
) -> Result<Vec<(String, String)>>
pub fn get_shell_functions_prefix_fts( &self, prefix: &str, ) -> Result<Vec<(String, String)>>
Fast prefix search using FTS5 (note: FTS5 doesn’t preserve order, needs post-sort)
Sourcepub fn get_shell_functions_prefix(
&self,
prefix: &str,
) -> Result<Vec<(String, String)>>
pub fn get_shell_functions_prefix( &self, prefix: &str, ) -> Result<Vec<(String, String)>>
Get shell functions matching prefix (LIKE with index, ORDER BY free)
Sourcepub fn shell_functions_count(&self) -> Result<i64>
pub fn shell_functions_count(&self) -> Result<i64>
Count shell functions
Sourcepub fn has_zstyles(&self) -> Result<bool>
pub fn has_zstyles(&self) -> Result<bool>
Check if zstyles cache is populated
Sourcepub fn zstyles_count(&self) -> Result<i64>
pub fn zstyles_count(&self) -> Result<i64>
Count zstyles
Auto Trait Implementations§
impl !Freeze for CompsysCache
impl !RefUnwindSafe for CompsysCache
impl !Sync for CompsysCache
impl !UnwindSafe for CompsysCache
impl Send for CompsysCache
impl Unpin for CompsysCache
impl UnsafeUnpin for CompsysCache
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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