1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
mod diagnostic;
#[cfg(feature = "lsp")]
mod lsp;
pub use notedown_ast::traits::ContextKind;
use crate::{
plugin_system::{Parser, PluginSystem},
VMFileSystem,
};
use std::path::Path;
use yggdrasil_shared::Url;
#[derive(Debug)]
pub struct NoteVM {
fs: VMFileSystem,
ps: PluginSystem,
}
impl Default for NoteVM {
fn default() -> Self {
Self { fs: Default::default(), ps: Default::default() }
}
}
impl NoteVM {
pub fn new(root: Url) -> NoteVM {
Self { fs: VMFileSystem::new(root), ps: Default::default() }
}
pub fn run() {}
#[inline]
pub async fn load_cache(&mut self, dump: &Path) {
let _ = dump;
todo!()
}
#[inline]
pub async fn dump_cache(&self, dump: &Path) {
let _ = dump;
todo!()
}
}
impl NoteVM {
#[inline]
pub fn gc(&self) {
self.fs.cache.retain(|_, v| v.can_gc())
}
#[inline]
pub fn gc_mark(&self, _: &Url) {
}
}
impl NoteVM {
#[inline]
async fn update_text(&self, url: &Url) -> bool {
match self.fs.update_text(url).await {
Ok(_) => true,
Err(_) => false,
}
}
#[inline]
async fn update_document(&self, url: &Url, parser: &Parser) -> bool {
match self.fs.update_ast(url, parser).await {
Ok(_) => true,
Err(_) => false,
}
}
pub async fn publish(&self) {}
}