1#[cfg(feature = "tokio")]
8pub mod tokio;
9
10use std::future::Future;
11use std::path::PathBuf;
12use std::pin::Pin;
13
14pub trait Fetch {
15 fn fetch(&self, path: PathBuf)
16 -> Pin<Box<dyn Future<Output = Result<String, std::io::Error>>>>;
17}
18
19#[derive(Debug, Default)]
20pub struct Null;
21
22impl Fetch for Null {
23 fn fetch(
24 &self,
25 _path: PathBuf,
26 ) -> Pin<Box<dyn Future<Output = Result<String, std::io::Error>>>> {
27 let fut = async { Err(std::io::ErrorKind::Unsupported.into()) };
28 Box::pin(fut)
29 }
30}
31
32#[cfg(feature = "tokio")]
33pub use self::tokio::Tokio as DefaultFetch;
34
35#[cfg(not(feature = "tokio"))]
36pub use self::Null as DefaultFetch;