Skip to main content

CypherDatabase

Struct CypherDatabase 

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

The concrete incremental database (Salsa 2022-style, spec §11.1).

§Send + Sync via snapshots (spec §11.5)

CypherDatabase is Send but not SyncZalsaLocal contains per-thread UnsafeCell state by design. Thread-safety is achieved via snapshots: clone() shares the Arc<Zalsa> backing store and produces a fresh ZalsaLocal, allowing the clone to be sent to another thread and queried concurrently. The LSP server clones once per request; the CLI never needs to.

Implementations§

Source§

impl CypherDatabase

Source

pub fn new() -> CypherDatabase

Construct a new, empty database.

Source

pub fn new_source_file(&mut self, source: impl Into<String>) -> SourceFile

Create a new SourceFile input with the given source text, using the default dialect and a zero options digest.

Source

pub fn new_source_file_with( &mut self, source: impl Into<String>, dialect: DialectMode, options_digest: u64, ) -> SourceFile

Create a new SourceFile input with explicit dialect and digest.

Source

pub fn set_source(&mut self, file: SourceFile, source: impl Into<String>)

Update the source text of an existing SourceFile, bumping the Salsa revision so that derived queries are invalidated.

Always clears any cy-li6 precomputed_parse hint, because a fresh source string must produce a fresh parse — reusing a stale hint would silently desync the published CST from source.

Source

pub fn set_source_with_parse( &mut self, file: SourceFile, source: impl Into<String>, parse: ParseOutput, )

Atomically replace source and publish a precomputed Parse (cy-li6).

Used by workspace::Database::edit_file after cyrs_syntax::incremental_reparse has produced a spliced tree for new_source. Bumps the Salsa revision once for both fields, so the next parse_cst query returns parse directly without re-parsing.

Source

pub fn set_dialect(&mut self, file: SourceFile, dialect: DialectMode)

Update the dialect of an existing SourceFile.

Source

pub fn new_file_options(&mut self, options: AnalysisOptions) -> FileOptions

Create a new FileOptions input with the given AnalysisOptions.

Source

pub fn set_options(&mut self, file_opts: FileOptions, options: AnalysisOptions)

Update the AnalysisOptions of an existing FileOptions input.

Bumps the Salsa revision for file_opts, which cascades through options_digest and all derived queries that read it.

Source

pub fn new_workspace_inputs( &mut self, schema: Option<Arc<dyn SchemaProvider>>, ) -> WorkspaceInputs

Create a new WorkspaceInputs input.

There should be exactly one WorkspaceInputs per database. Call this once at database initialisation; update it with set_schema.

Source

pub fn set_schema( &mut self, ws: WorkspaceInputs, schema: Option<Arc<dyn SchemaProvider>>, )

Update the workspace-scoped schema.

Invalidates all derived queries that depend on the schema.

Trait Implementations§

Source§

impl Clone for CypherDatabase

Source§

fn clone(&self) -> CypherDatabase

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Database for CypherDatabase

Source§

fn trigger_lru_eviction(&mut self)

Enforces current LRU limits, evicting entries if necessary. Read more
Source§

fn synthetic_write(&mut self, durability: Durability)

A “synthetic write” causes the system to act as though some input of durability durability has changed, triggering a new revision. This is mostly useful for profiling scenarios. Read more
Source§

fn trigger_cancellation(&mut self)

This method cancels all outstanding computations. If you invoke it while a snapshot exists, it will block until that snapshot is dropped – if that snapshot is owned by the current thread, this could trigger deadlock.
Source§

fn cancellation_token(&self) -> CancellationToken

Retrieves a CancellationToken for the current database handle.
Source§

fn report_untracked_read(&self)

Reports that the query depends on some state unknown to salsa. Read more
Source§

fn ingredient_debug_name( &self, ingredient_index: IngredientIndex, ) -> Cow<'_, str>

Return the “debug name” (i.e., the struct name, etc) for an “ingredient”, which are the fine-grained components we use to track data. This is intended for debugging and the contents of the returned string are not semver-guaranteed. Read more
Source§

fn unwind_if_revision_cancelled(&self)

Starts unwinding the stack if the current revision is cancelled. Read more
Source§

fn attach<R>(&self, op: impl FnOnce(&Self) -> R) -> R
where Self: Sized,

Execute op with the database in thread-local storage for debug print-outs.
Source§

impl Debug for CypherDatabase

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for CypherDatabase

Source§

fn default() -> CypherDatabase

Returns the “default value” for a type. Read more
Source§

impl CypherDb for CypherDatabase

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> 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Lookup<T> for T

Source§

fn into_owned(self) -> T

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<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