pub struct DatabaseSnapshot { /* private fields */ }Expand description
A read-only, Send snapshot of the database at a point in time.
Obtained via Database::snapshot. The snapshot shares the
Arc<Zalsa> backing store with the origin Database and sees a
frozen view of the Salsa revision at the moment of cloning. Subsequent
mutations to the Database are invisible to this snapshot.
Snapshots are suitable for cross-thread queries: they implement Send
so they can be shipped to a worker thread for concurrent read queries.
§Example
let snap = db.snapshot();
let file = /* FileId from the origin db */;
let result = std::thread::spawn(move || {
snap.parse_cst(file).unwrap()
}).join().unwrap();Implementations§
Source§impl DatabaseSnapshot
impl DatabaseSnapshot
Sourcepub fn parse_cst(&self, id: FileId) -> Result<ParseOutput, UnknownFileId>
pub fn parse_cst(&self, id: FileId) -> Result<ParseOutput, UnknownFileId>
Run parse_cst on the given file using this snapshot’s view.
Returns Err(UnknownFileId) if id was not open at snapshot time.
Sourcepub fn parse_ast(&self, id: FileId) -> Result<AstOutput, UnknownFileId>
pub fn parse_ast(&self, id: FileId) -> Result<AstOutput, UnknownFileId>
Run parse_ast on the given file using this snapshot’s view.
Sourcepub fn plan_of(&self, id: FileId) -> Result<PlanOutput, UnknownFileId>
pub fn plan_of(&self, id: FileId) -> Result<PlanOutput, UnknownFileId>
Run plan_of on the given file using this snapshot’s view.
Sourcepub fn sema_diagnostics(
&self,
id: FileId,
) -> Result<DiagnosticsOutput, UnknownFileId>
pub fn sema_diagnostics( &self, id: FileId, ) -> Result<DiagnosticsOutput, UnknownFileId>
Run sema_diagnostics on the given file using this snapshot’s view.
Sourcepub fn resolved_names(
&self,
id: FileId,
) -> Result<ResolvedNamesOutput, UnknownFileId>
pub fn resolved_names( &self, id: FileId, ) -> Result<ResolvedNamesOutput, UnknownFileId>
Run resolved_names on the given file using this snapshot’s view.
Sourcepub fn all_diagnostics(
&self,
id: FileId,
) -> Result<DiagnosticsOutput, UnknownFileId>
pub fn all_diagnostics( &self, id: FileId, ) -> Result<DiagnosticsOutput, UnknownFileId>
Run all_diagnostics on the given file using this snapshot’s view.
Sourcepub fn analyse_file(&self, id: FileId) -> Result<Analysis, UnknownFileId>
pub fn analyse_file(&self, id: FileId) -> Result<Analysis, UnknownFileId>
Run the full analysis pipeline on the given file using this snapshot’s view.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DatabaseSnapshot
impl RefUnwindSafe for DatabaseSnapshot
impl Send for DatabaseSnapshot
impl !Sync for DatabaseSnapshot
impl Unpin for DatabaseSnapshot
impl UnsafeUnpin for DatabaseSnapshot
impl !UnwindSafe for DatabaseSnapshot
Blanket Implementations§
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 more