Skip to main content

trillium_static/
fs_shims.rs

1cfg_if::cfg_if! {
2    if #[cfg(feature = "tokio")] {
3       pub(crate) use tokio_crate::fs::{self, File};
4    } else if #[cfg(feature = "async-std")] {
5        pub(crate) use async_std_crate::fs::{self, File};
6    } else if #[cfg(feature = "smol")] {
7        pub(crate) use async_fs::{self as fs, File};
8    } else {
9        #[derive(Debug, Clone, Copy)]
10        pub struct File;
11        impl File {
12            pub(crate) async fn open(_path: impl AsRef<std::path::Path>) -> std::io::Result<Self> {
13                unimplemented!("please enable the tokio, async-std, or smol runtime feature")
14            }
15
16            pub(crate) async fn metadata(&self) -> std::io::Result<std::fs::Metadata> {
17                unimplemented!("please enable the tokio, async-std, or smol runtime feature")
18            }
19        }
20
21        impl futures_lite::AsyncRead for File {
22            fn poll_read(
23                self: std::pin::Pin<&mut Self>,
24                _cx: &mut std::task::Context<'_>,
25                _buf: &mut [u8],
26            ) -> std::task::Poll<std::io::Result<usize>> {
27                unimplemented!("please enable the tokio, async-std, or smol runtime feature")
28
29            }
30        }
31
32
33
34        pub(crate) mod fs {
35            pub(crate) async fn canonicalize(_path: impl AsRef<std::path::Path>) -> std::io::Result<std::path::PathBuf> {
36                unimplemented!("please enable the tokio, async-std, or smol runtime feature")
37            }
38
39            pub(crate) async fn metadata(_path: impl AsRef<std::path::Path>) -> std::io::Result<std::fs::Metadata> {
40                unimplemented!("please enable the tokio, async-std, or smol runtime feature")
41            }
42        }
43    }
44}