VenusDatabase

Struct VenusDatabase 

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

The concrete database implementation.

This is the main entry point for incremental computation in Venus. Create an instance with VenusDatabase::new() and use the helper methods to interact with the incremental system.

Implementations§

Source§

impl VenusDatabase

Source

pub fn new() -> Self

Create a new Venus database.

Source

pub fn set_source(&self, path: PathBuf, text: String) -> SourceFile

Create a new source file input.

Returns a handle that can be used with query functions.

Source

pub fn update_source(&mut self, source: SourceFile, text: String)

Update an existing source file’s content.

This will invalidate all queries that depend on this source.

Source

pub fn get_cells(&self, source: SourceFile) -> Vec<CellData>

Parse cells from a source file.

Returns the list of cells extracted from the source. Returns an empty vector on parse errors.

Source

pub fn get_cells_result(&self, source: SourceFile) -> QueryResult<Vec<CellData>>

Parse cells from a source file with error reporting.

Returns QueryResult::Ok with cells on success, or QueryResult::Err with an error message on parse failure.

Source

pub fn get_cell_names(&self, source: SourceFile) -> Vec<String>

Get cell names from a source file.

Source

pub fn get_execution_order(&self, source: SourceFile) -> Vec<usize>

Get the execution order for a notebook.

Returns cell indices in topological order. Returns an empty vector on graph errors.

Source

pub fn get_execution_order_result( &self, source: SourceFile, ) -> QueryResult<Vec<usize>>

Get the execution order for a notebook with error reporting.

Returns QueryResult::Ok with ordered indices on success, or QueryResult::Err with an error message on graph errors (cycles, missing dependencies, etc.).

Source

pub fn get_invalidated( &self, source: SourceFile, changed_idx: usize, ) -> Vec<usize>

Get cells invalidated by a change.

Returns all cells that need to be re-executed when the given cell changes.

Source

pub fn get_parallel_levels(&self, source: SourceFile) -> Vec<Vec<usize>>

Get parallel execution levels.

Returns groups of cells that can be executed in parallel.

Source

pub fn create_compiler_settings( &self, build_dir: PathBuf, cache_dir: PathBuf, universe_path: Option<PathBuf>, use_cranelift: bool, opt_level: u8, ) -> CompilerSettings

Create compiler settings input.

Source

pub fn get_dependency_hash(&self, source: SourceFile) -> u64

Get the dependency hash for a notebook.

This hash represents all external crate dependencies.

Source

pub fn compile_cell( &self, source: SourceFile, cell_idx: usize, settings: CompilerSettings, ) -> CompilationStatus

Compile a specific cell.

Returns the compilation status (success, cached, or failed).

Source

pub fn compile_all( &self, source: SourceFile, settings: CompilerSettings, ) -> Arc<Vec<CompilationStatus>>

Compile all cells in execution order.

Returns compilation results for all cells.

Source

pub fn create_cell_outputs(&self, cell_count: usize) -> CellOutputs

Create a new cell outputs input with all cells pending.

Call this after parsing cells to initialize the outputs tracking.

Source

pub fn set_cell_output( &mut self, outputs: CellOutputs, cell_idx: usize, status: ExecutionStatus, )

Update the execution status for a specific cell.

This will increment the version counter and invalidate any queries that depend on this cell’s output.

§Panics

In debug builds, panics if cell_idx is out of bounds. In release builds, out-of-bounds indices are silently ignored (but version is still incremented, which may cause unnecessary invalidations).

§Example
let outputs = db.create_cell_outputs(3);
db.set_cell_output(outputs, 0, ExecutionStatus::Running);
Source

pub fn get_cell_output( &self, outputs: CellOutputs, cell_idx: usize, ) -> ExecutionStatus

Get the execution status for a specific cell.

Returns ExecutionStatus::Pending if the cell index is out of bounds.

Source

pub fn get_cell_output_data( &self, outputs: CellOutputs, cell_idx: usize, ) -> Option<CellOutputData>

Get the output data for a cell if it executed successfully.

Returns None if the cell is pending, running, failed, or out of bounds.

Source

pub fn are_all_cells_executed(&self, outputs: CellOutputs) -> bool

Check if all cells have finished executing.

Source

pub fn mark_cell_running(&mut self, outputs: CellOutputs, cell_idx: usize)

Mark a cell as currently running.

§Panics

In debug builds, panics if cell_idx is out of bounds.

Source

pub fn mark_cell_failed( &mut self, outputs: CellOutputs, cell_idx: usize, error: String, )

Mark a cell as failed with an error message.

§Panics

In debug builds, panics if cell_idx is out of bounds.

Source

pub fn mark_cell_success( &mut self, outputs: CellOutputs, cell_idx: usize, output: CellOutputData, )

Mark a cell as successfully executed with output data.

§Panics

In debug builds, panics if cell_idx is out of bounds.

Source

pub fn create_cache_snapshot( &self, toolchain_version: String, dependency_hash: u64, cells: Vec<(String, u64, CompilationStatus)>, ) -> CacheSnapshot

Create a cache snapshot from current compilation state.

This captures all successfully compiled cells so they can be restored on the next startup without recompilation.

§Arguments
  • toolchain_version - Current rustc version string
  • dependency_hash - Hash of external dependencies
  • cells - List of (name, source_hash, compilation_status)
§Example
let snapshot = db.create_cache_snapshot(
    toolchain.version().to_string(),
    db.get_dependency_hash(source),
    compiled_cells,
);
CachePersistence::save(&cache_path, &snapshot)?;
Source

pub fn is_cell_cached( &self, snapshot: &CacheSnapshot, cell_name: &str, current_source_hash: u64, ) -> bool

Check if a cached cell can be reused.

Returns true if the cell exists in the cache with a matching source hash and successful compilation status.

Source

pub fn get_cached_dylib_path( &self, snapshot: &CacheSnapshot, cell_name: &str, ) -> Option<PathBuf>

Get the dylib path for a cached cell.

Returns None if the cell is not in cache or failed compilation.

Trait Implementations§

Source§

impl Clone for VenusDatabase

Source§

fn clone(&self) -> VenusDatabase

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Database for VenusDatabase

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 triggers cancellation. 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 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 Default for VenusDatabase

Source§

fn default() -> VenusDatabase

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

impl HasStorage for VenusDatabase

Source§

fn storage(&self) -> &Storage<Self>

Source§

fn storage_mut(&mut self) -> &mut Storage<Self>

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

Source§

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

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
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 metadata type for pointers and references to this type.
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