pub struct StateManager { /* private fields */ }Expand description
Manages cell state persistence and invalidation.
Implementations§
Source§impl StateManager
impl StateManager
Sourcepub fn new(state_dir: impl AsRef<Path>) -> Result<Self>
pub fn new(state_dir: impl AsRef<Path>) -> Result<Self>
Create a new state manager with the given state directory.
Sourcepub fn save<T: CellOutput>(&mut self, cell_id: CellId, value: &T) -> Result<()>
pub fn save<T: CellOutput>(&mut self, cell_id: CellId, value: &T) -> Result<()>
Save a cell output.
Sourcepub fn get_output(&self, cell_id: CellId) -> Option<Arc<BoxedOutput>>
pub fn get_output(&self, cell_id: CellId) -> Option<Arc<BoxedOutput>>
Get a reference to a cached output without deserializing.
Sourcepub fn store_output(&mut self, cell_id: CellId, output: BoxedOutput)
pub fn store_output(&mut self, cell_id: CellId, output: BoxedOutput)
Store a pre-serialized output directly.
Used by the execution engine to store outputs from FFI calls.
Sourcepub fn has_output(&self, cell_id: CellId) -> bool
pub fn has_output(&self, cell_id: CellId) -> bool
Check if a cell has a cached output.
Sourcepub fn invalidate(&mut self, cell_id: CellId)
pub fn invalidate(&mut self, cell_id: CellId)
Invalidate a cell’s output (e.g., when its source changes).
Sourcepub fn invalidate_many(&mut self, cell_ids: &[CellId])
pub fn invalidate_many(&mut self, cell_ids: &[CellId])
Invalidate multiple cells.
Sourcepub fn on_cell_modified(
&mut self,
cell_id: CellId,
dependents: &[CellId],
) -> Vec<CellId>
pub fn on_cell_modified( &mut self, cell_id: CellId, dependents: &[CellId], ) -> Vec<CellId>
Called when a cell is modified - invalidates it and all dependents.
Returns the list of invalidated cell IDs.
Sourcepub fn update_fingerprint(
&mut self,
cell_id: CellId,
new_fingerprint: TypeFingerprint,
) -> SchemaChange
pub fn update_fingerprint( &mut self, cell_id: CellId, new_fingerprint: TypeFingerprint, ) -> SchemaChange
Update the type fingerprint for a cell and check for schema changes.
Sourcepub fn flush(&mut self) -> Result<()>
pub fn flush(&mut self) -> Result<()>
Persist all dirty outputs to disk.
Uses atomic write pattern to prevent partial state corruption. If any write fails, failed cells remain marked as dirty.
Sourcepub fn sync_output_to_salsa(
&self,
cell_id: CellId,
inputs_hash: u64,
execution_time_ms: u64,
) -> Option<CellOutputData>
pub fn sync_output_to_salsa( &self, cell_id: CellId, inputs_hash: u64, execution_time_ms: u64, ) -> Option<CellOutputData>
Convert a single cell output to Salsa-compatible format.
Returns None if the cell has no cached output.
§Arguments
cell_id- The cell to exportinputs_hash- Hash of the cell’s input values (for staleness detection)execution_time_ms- How long the cell took to execute
Sourcepub fn sync_all_to_salsa<F, G>(
&self,
cell_count: usize,
get_inputs_hash: F,
get_execution_time: G,
) -> Vec<ExecutionStatus>
pub fn sync_all_to_salsa<F, G>( &self, cell_count: usize, get_inputs_hash: F, get_execution_time: G, ) -> Vec<ExecutionStatus>
Export all outputs to a vector of execution statuses for Salsa.
Creates a vector sized to cell_count where each index corresponds
to a cell ID. Cells without outputs are marked as Pending.
§Arguments
cell_count- Total number of cells in the notebookget_inputs_hash- Closure to get the inputs hash for each cellget_execution_time- Closure to get execution time for each cell (0 if unknown)
Sourcepub fn load_from_salsa(&mut self, output_data: &CellOutputData)
pub fn load_from_salsa(&mut self, output_data: &CellOutputData)
Import an output from Salsa’s cached data.
Converts a CellOutputData back to a BoxedOutput and stores it.
Sourcepub fn load_all_from_salsa(&mut self, statuses: &[ExecutionStatus]) -> usize
pub fn load_all_from_salsa(&mut self, statuses: &[ExecutionStatus]) -> usize
Import all successful outputs from Salsa’s execution statuses.
Returns the number of outputs imported.
Sourcepub fn is_salsa_output_valid(
&self,
cell_id: CellId,
_current_inputs_hash: u64,
) -> bool
pub fn is_salsa_output_valid( &self, cell_id: CellId, _current_inputs_hash: u64, ) -> bool
Check if a Salsa output is still valid for the current inputs.
Note: The StateManager doesn’t store input hashes, so this method only
checks if an output exists. For actual validation, use the is_valid_for()
method on CellOutputData with the Salsa-cached output.
The _current_inputs_hash parameter is reserved for future use when
input hash tracking is added to the StateManager.
Auto Trait Implementations§
impl Freeze for StateManager
impl RefUnwindSafe for StateManager
impl Send for StateManager
impl Sync for StateManager
impl Unpin for StateManager
impl UnwindSafe for StateManager
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
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.