mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-27 04:19:22 +00:00
introduce salsa and integrate into djls-project crate (#139)
This commit is contained in:
parent
0c041e20d7
commit
ccf33290b3
11 changed files with 896 additions and 670 deletions
31
crates/djls-project/src/db.rs
Normal file
31
crates/djls-project/src/db.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use crate::meta::ProjectMetadata;
|
||||
|
||||
#[salsa::db]
|
||||
pub trait Db: salsa::Database {
|
||||
fn metadata(&self) -> &ProjectMetadata;
|
||||
}
|
||||
|
||||
#[salsa::db]
|
||||
#[derive(Clone)]
|
||||
pub struct ProjectDatabase {
|
||||
storage: salsa::Storage<ProjectDatabase>,
|
||||
metadata: ProjectMetadata,
|
||||
}
|
||||
|
||||
impl ProjectDatabase {
|
||||
pub fn new(metadata: ProjectMetadata) -> Self {
|
||||
let storage = salsa::Storage::new(None);
|
||||
|
||||
Self { storage, metadata }
|
||||
}
|
||||
}
|
||||
|
||||
#[salsa::db]
|
||||
impl Db for ProjectDatabase {
|
||||
fn metadata(&self) -> &ProjectMetadata {
|
||||
&self.metadata
|
||||
}
|
||||
}
|
||||
|
||||
#[salsa::db]
|
||||
impl salsa::Database for ProjectDatabase {}
|
Loading…
Add table
Add a link
Reference in a new issue