1use std::sync::Arc;
2
3use bevy_ecs::prelude::Resource;
4use derive_more::derive::AsRef;
5
6#[derive(Resource, Clone, AsRef, Debug)]
7pub struct Fs(pub Arc<dyn FsTrait>);
8
9#[tower_lsp::async_trait]
10pub trait FsTrait: Send + Sync + 'static + std::fmt::Debug {
11 fn virtual_url(&self, url: &str) -> Option<lsp_types::Url>;
12 fn lov_url(&self, url: &str, prefix: &str) -> Option<lsp_types::Url> {
13 if !url.starts_with("http") {
14 return None;
15 }
16 let url = self.virtual_url(&format!("{}.ttl", prefix))?;
17 tracing::info!("lov url {} {} -> {}", url, prefix, url);
18 Some(url)
19 }
20 async fn read_file(&self, url: &lsp_types::Url) -> Option<String>;
21 async fn write_file(&self, url: &lsp_types::Url, content: &str) -> Option<()>;
22}