Skip to main content

CompsysCache

Struct CompsysCache 

Source
pub struct CompsysCache { /* private fields */ }
Expand description

SQLite cache for completion system

Implementations§

Source§

impl CompsysCache

Source

pub fn conn(&self) -> &Connection

Access the underlying SQLite connection (for dbview etc.)

Source

pub fn count_table(&self, table: &str) -> Result<usize>

Count rows in a table.

Source

pub fn count_table_where(&self, table: &str, condition: &str) -> Result<usize>

Count rows matching a WHERE clause.

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open or create cache database with maximum performance settings

Source

pub fn memory() -> Result<Self>

In-memory cache (for testing)

Source

pub fn add_autoload( &self, name: &str, source: &str, offset: i64, size: i64, ) -> Result<()>

Register an autoload stub (without body)

Source

pub fn add_autoload_with_body( &self, name: &str, source: &str, body: &str, ) -> Result<()>

Register an autoload with full function body (for instant loading)

Source

pub fn add_autoloads_bulk( &mut self, autoloads: &[(String, String, i64, i64)], ) -> Result<()>

Bulk insert autoloads (much faster)

Source

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)

Source

pub fn get_autoload(&self, name: &str) -> Result<Option<AutoloadStub>>

Lookup autoload by name

Source

pub fn get_autoload_body(&self, name: &str) -> Result<Option<String>>

Get function body directly (fast path for autoload -Xz)

Source

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).

Source

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.

Source

pub fn get_autoload_body_or_zwc(&self, name: &str) -> Option<String>

Get function body with ZWC fallback

  1. If body column has content, return it (fast path)
  2. If body is NULL but source/offset/size exist, read from ZWC file
  3. Returns None if function not found or ZWC read fails
Source

pub fn autoload_count(&self) -> Result<i64>

Count autoloads

Source

pub fn list_autoloads(&self, limit: usize) -> Result<Vec<String>>

List all autoload names (for debugging)

Source

pub fn list_autoload_names(&self) -> Result<Vec<String>>

List all autoload names (no limit)

Source

pub fn set_zstyle( &self, pattern: &str, style: &str, values: &[String], eval: bool, ) -> Result<()>

Set a zstyle

Source

pub fn set_zstyles_bulk( &mut self, styles: &[(String, String, Vec<String>, bool)], ) -> Result<()>

Bulk insert zstyles

Source

pub fn delete_zstyle(&self, pattern: &str, style: Option<&str>) -> Result<usize>

Delete a zstyle

Source

pub fn lookup_zstyle( &self, context: &str, style: &str, ) -> Result<Option<ZStyleEntry>>

Lookup zstyle - returns all matching patterns sorted by specificity

Source

pub fn list_zstyles(&self) -> Result<Vec<(String, String, Vec<String>, bool)>>

List all zstyles (for zstyle -L)

Source

pub fn zstyle_count(&self) -> Result<i64>

Count zstyles

Source

pub fn set_comp(&self, command: &str, function: &str) -> Result<()>

Register a completion function for a command

Source

pub fn set_comps_bulk(&mut self, comps: &[(String, String)]) -> Result<()>

Bulk insert comps + populate FTS5 index

Source

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)

Source

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)

Source

pub fn get_comp(&self, command: &str) -> Result<Option<String>>

Lookup completion function for command

Source

pub fn get_all_comps(&self) -> Result<HashMap<String, String>>

Get all comps as HashMap (for compatibility)

Source

pub fn comp_count(&self) -> Result<i64>

Count comps

Source

pub fn delete_comp(&self, command: &str) -> Result<usize>

Delete a completion registration

Source

pub fn set_patcomp(&self, pattern: &str, function: &str) -> Result<()>

Register a pattern completion

Source

pub fn find_patcomp(&self, command: &str) -> Result<Option<String>>

Find matching pattern completion

Source

pub fn set_keycomp(&self, key: &str, function: &str) -> Result<()>

Register a key completion (for -K)

Source

pub fn get_keycomp(&self, key: &str) -> Result<Option<String>>

Lookup key completion

Source

pub fn cache_results( &self, context: &str, data: &[u8], mtime: i64, ) -> Result<()>

Cache completion results

Source

pub fn get_cached(&self, context: &str, max_age: i64) -> Result<Option<Vec<u8>>>

Get cached results if not stale

Source

pub fn clear_stale_cache(&self, max_age: i64) -> Result<usize>

Clear old cache entries

Source

pub fn clear_cache(&self) -> Result<()>

Clear all cache

Source

pub fn vacuum(&self) -> Result<()>

Vacuum database

Source

pub fn stats(&self) -> Result<CacheStats>

Get database stats

Source§

impl CompsysCache

Source

pub fn comps_count(&self) -> Result<i64>

Get count of _comps entries (for $#_comps)

Source

pub fn comps_keys(&self) -> Result<Vec<String>>

Get all _comps keys (for ${(k)_comps}) - ORDER BY is free on PRIMARY KEY

Source

pub fn comps_values(&self) -> Result<Vec<String>>

Get all _comps values (for ${(v)_comps})

Source

pub fn comps_kv(&self) -> Result<Vec<(String, String)>>

Get _comps as key-value pairs (for ${(kv)_comps})

Source

pub fn patcomps_count(&self) -> Result<i64>

Get count of _patcomps

Source

pub fn patcomps_keys(&self) -> Result<Vec<String>>

Get all _patcomps keys

Source

pub fn patcomps_kv(&self) -> Result<Vec<(String, String)>>

Get all _patcomps as kv

Source

pub fn set_service(&self, command: &str, service: &str) -> Result<()>

Set a service mapping

Source

pub fn get_service(&self, command: &str) -> Result<Option<String>>

Get service for command

Source

pub fn services_count(&self) -> Result<i64>

Get count of _services

Source

pub fn services_keys(&self) -> Result<Vec<String>>

Get all _services keys

Source

pub fn set_services_bulk(&mut self, services: &[(String, String)]) -> Result<()>

Bulk insert services

Source

pub fn compautos_count(&self) -> Result<i64>

Get count of autoloaded functions

Source

pub fn compautos_keys(&self) -> Result<Vec<String>>

Get all autoload names (for ${(k)_compautos})

Source

pub fn has_executables(&self) -> Result<bool>

Check if executables cache is populated

Source

pub fn set_executables_bulk( &mut self, executables: &[(String, String)], ) -> Result<()>

Store executables in bulk + populate FTS5 index

Source

pub fn get_executable_names(&self) -> Result<HashSet<String>>

Get all executable names (fast lookup set)

Source

pub fn has_executable(&self, name: &str) -> Result<bool>

Check if an executable exists in cache (O(1) lookup)

Source

pub fn get_executable_path(&self, name: &str) -> Result<Option<String>>

Get executable path by name (direct key lookup)

Source

pub fn get_executables_prefix_fts( &self, prefix: &str, ) -> Result<Vec<(String, String)>>

Fast prefix search using FTS5

Source

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)

Source

pub fn executables_count(&self) -> Result<i64>

Count executables

Source

pub fn has_named_dirs(&self) -> Result<bool>

Check if named_dirs cache is populated

Source

pub fn set_named_dirs_bulk(&mut self, dirs: &[(String, String)]) -> Result<()>

Store named directories in bulk (clears existing)

Source

pub fn get_named_dirs(&self) -> Result<Vec<(String, String)>>

Get all named directories (ORDER BY free on PRIMARY KEY)

Source

pub fn get_named_dirs_prefix( &self, prefix: &str, ) -> Result<Vec<(String, String)>>

Get named directories matching prefix

Source

pub fn named_dirs_count(&self) -> Result<i64>

Count named directories

Source

pub fn has_shell_functions(&self) -> Result<bool>

Check if shell_functions cache is populated

Source

pub fn set_shell_functions_bulk( &mut self, funcs: &[(String, String)], ) -> Result<()>

Store shell functions in bulk + populate FTS5 index

Source

pub fn get_shell_function_names(&self) -> Result<Vec<String>>

Get all shell function names (ORDER BY free on PRIMARY KEY)

Source

pub fn get_shell_functions(&self) -> Result<Vec<(String, String)>>

Get shell functions with source paths

Source

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)

Source

pub fn get_shell_functions_prefix( &self, prefix: &str, ) -> Result<Vec<(String, String)>>

Get shell functions matching prefix (LIKE with index, ORDER BY free)

Source

pub fn shell_functions_count(&self) -> Result<i64>

Count shell functions

Source

pub fn set_metadata(&self, key: &str, value: &str) -> Result<()>

Set metadata key-value

Source

pub fn get_metadata(&self, key: &str) -> Result<Option<String>>

Get metadata value

Source

pub fn has_zstyles(&self) -> Result<bool>

Check if zstyles cache is populated

Source

pub fn zstyles_count(&self) -> Result<i64>

Count zstyles

Source

pub fn get_all_zstyles(&self) -> Result<Vec<(String, String, String)>>

Get all zstyles (for debugging)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more