Skip to main content

sos_client/source/
base.rs

1#[cfg(not(feature = "look-ahead"))]
2use std::path::Path;
3use std::path::PathBuf;
4
5use crate::error::Result;
6
7pub trait SourceTrait {
8    type Code;
9
10    #[cfg(all(feature = "look-ahead", not(feature = "cache")))]
11    type PrebuiltCode;
12    #[cfg(all(feature = "look-ahead", feature = "cache"))]
13    type PrebuiltCode: serde::Serialize + serde::de::DeserializeOwned;
14
15    #[cfg(feature = "look-ahead")]
16    fn compile_source(&self, source: Self::PrebuiltCode) -> Result<Self::Code>;
17    #[cfg(not(feature = "look-ahead"))]
18    fn compile_source(&self, source: String) -> Result<Self::Code>;
19
20    #[cfg(feature = "look-ahead")]
21    fn source_file_postfix(&self) -> &[&str];
22
23    #[cfg(feature = "look-ahead")]
24    fn prebuild(&self, path: PathBuf, source: String) -> Option<(String, Self::PrebuiltCode)>;
25
26    #[cfg(not(feature = "look-ahead"))]
27    fn name_to_file(&self, root: &Path, name: &str) -> PathBuf;
28}