Skip to content

Commit 877bce4

Browse files
committed
feat(dir-structure): finished making it generic over path types
1 parent 858b09f commit 877bce4

File tree

56 files changed

+1065
-817
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1065
-817
lines changed

doc/docs/content/docs/dx/dir-structure/.custom-impl.mdx.doctests

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
/// use std::pin::Pin;
4242
/// use std::time::SystemTime;
4343
///
44-
/// use dir_structure::{error::Result, traits::vfs, prelude::*};
44+
/// use dir_structure::{error::VfsResult, traits::vfs, prelude::*};
4545
///
4646
/// // !collapse(1:4) collapsed
4747
/// struct FsMtime<T> {
@@ -50,8 +50,8 @@
5050
/// }
5151
///
5252
/// // !mark(1:5)
53-
/// impl<'vfs, Vfs: vfs::Vfs<'vfs>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
54-
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> Result<Self> {
53+
/// impl<'vfs, Vfs: vfs::Vfs<'vfs, Path=Path>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
54+
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<Self, Vfs> {
5555
/// todo!()
5656
/// }
5757
/// }
@@ -68,16 +68,16 @@
6868
/// use std::pin::Pin;
6969
/// use std::time::SystemTime;
7070
///
71-
/// use dir_structure::{error::Result, traits::vfs, error::WrapIoError, prelude::*};
71+
/// use dir_structure::{error::VfsResult, traits::vfs, error::WrapIoError, prelude::*};
7272
///
7373
/// // !collapse(1:4) collapsed
7474
/// struct FsMtime<T> {
7575
/// mtime: SystemTime,
7676
/// value: T,
7777
/// }
7878
///
79-
/// impl<'vfs, Vfs: vfs::Vfs<'vfs>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
80-
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> Result<Self> {
79+
/// impl<'vfs, Vfs: vfs::Vfs<'vfs, Path=Path>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
80+
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<Self, Vfs> {
8181
/// // !mark(1:3)
8282
/// let mtime = path.metadata()
8383
/// .and_then(|m| m.modified())
@@ -98,16 +98,16 @@
9898
/// use std::pin::Pin;
9999
/// use std::time::SystemTime;
100100
///
101-
/// use dir_structure::{error::Result, traits::vfs, error::WrapIoError, prelude::*};
101+
/// use dir_structure::{error::VfsResult, traits::vfs, error::WrapIoError, prelude::*};
102102
///
103103
/// // !collapse(1:4) collapsed
104104
/// struct FsMtime<T> {
105105
/// mtime: SystemTime,
106106
/// value: T,
107107
/// }
108108
///
109-
/// impl<'vfs, Vfs: vfs::Vfs<'vfs>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
110-
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> Result<Self> {
109+
/// impl<'vfs, Vfs: vfs::Vfs<'vfs, Path=Path>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
110+
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<Self, Vfs> {
111111
/// let mtime = path.metadata()
112112
/// .and_then(|m| m.modified())
113113
/// .wrap_io_error_with(path)?;
@@ -129,7 +129,7 @@
129129
/// use std::pin::Pin;
130130
/// use std::time::SystemTime;
131131
///
132-
/// use dir_structure::{error::Result, traits::vfs, error::WrapIoError, prelude::*};
132+
/// use dir_structure::{error::VfsResult, traits::vfs, error::WrapIoError, prelude::*};
133133
///
134134
/// // !collapse(1:4) collapsed
135135
/// struct FsMtime<T> {
@@ -138,8 +138,8 @@
138138
/// }
139139
///
140140
/// // !collapse(1:9)
141-
/// impl<'vfs, Vfs: vfs::Vfs<'vfs>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
142-
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> Result<Self> {
141+
/// impl<'vfs, Vfs: vfs::Vfs<'vfs, Path=Path>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
142+
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<Self, Vfs> {
143143
/// let mtime = path.metadata()
144144
/// .and_then(|m| m.modified())
145145
/// .wrap_io_error_with(path)?;
@@ -161,7 +161,7 @@
161161
/// use std::pin::Pin;
162162
/// use std::time::SystemTime;
163163
///
164-
/// use dir_structure::{error::Result, traits::vfs, error::WrapIoError, prelude::*};
164+
/// use dir_structure::{error::VfsResult, traits::vfs, error::WrapIoError, prelude::*};
165165
///
166166
/// // !collapse(1:4) collapsed
167167
/// struct FsMtime<T> {
@@ -170,8 +170,8 @@
170170
/// }
171171
///
172172
/// // !collapse(1:9) collapsed
173-
/// impl<'vfs, Vfs: vfs::Vfs<'vfs>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
174-
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> Result<Self> {
173+
/// impl<'vfs, Vfs: vfs::Vfs<'vfs, Path=Path>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
174+
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<Self, Vfs> {
175175
/// let mtime = path.metadata()
176176
/// .and_then(|m| m.modified())
177177
/// .wrap_io_error_with(path)?;
@@ -181,8 +181,8 @@
181181
/// }
182182
///
183183
/// // !mark(1:6)
184-
/// impl<'vfs, Vfs: vfs::WriteSupportingVfs<'vfs>, T: WriteTo<'vfs, Vfs>> WriteTo<'vfs, Vfs> for FsMtime<T> {
185-
/// fn write_to(&self, path: &Path, vfs: Pin<&'vfs Vfs>) -> Result<()> {
184+
/// impl<'vfs, Vfs: vfs::WriteSupportingVfs<'vfs, Path=Path>, T: WriteTo<'vfs, Vfs>> WriteTo<'vfs, Vfs> for FsMtime<T> {
185+
/// fn write_to(&self, path: &Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<(), Vfs> {
186186
/// todo!();
187187
/// Ok(())
188188
/// }
@@ -200,7 +200,7 @@
200200
/// use std::pin::Pin;
201201
/// use std::time::SystemTime;
202202
///
203-
/// use dir_structure::{error::Result, traits::vfs, error::WrapIoError, prelude::*};
203+
/// use dir_structure::{error::VfsResult, traits::vfs, error::WrapIoError, prelude::*};
204204
///
205205
/// // !collapse(1:4) collapsed
206206
/// struct FsMtime<T> {
@@ -209,8 +209,8 @@
209209
/// }
210210
///
211211
/// // !collapse(1:9) collapsed
212-
/// impl<'vfs, Vfs: vfs::Vfs<'vfs>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
213-
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> Result<Self> {
212+
/// impl<'vfs, Vfs: vfs::Vfs<'vfs, Path=Path>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
213+
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<Self, Vfs> {
214214
/// let mtime = path.metadata()
215215
/// .and_then(|m| m.modified())
216216
/// .wrap_io_error_with(path)?;
@@ -219,8 +219,8 @@
219219
/// }
220220
/// }
221221
///
222-
/// impl<'vfs, Vfs: vfs::WriteSupportingVfs<'vfs>, T: WriteTo<'vfs, Vfs>> WriteTo<'vfs, Vfs> for FsMtime<T> {
223-
/// fn write_to(&self, path: &Path, vfs: Pin<&'vfs Vfs>) -> Result<()> {
222+
/// impl<'vfs, Vfs: vfs::WriteSupportingVfs<'vfs, Path=Path>, T: WriteTo<'vfs, Vfs>> WriteTo<'vfs, Vfs> for FsMtime<T> {
223+
/// fn write_to(&self, path: &Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<(), Vfs> {
224224
/// // !mark
225225
/// self.value.write_to(path, vfs)?;
226226
/// todo!();
@@ -239,7 +239,7 @@
239239
/// use std::pin::Pin;
240240
/// use std::time::SystemTime;
241241
///
242-
/// use dir_structure::{error::Result, traits::vfs, error::WrapIoError, prelude::*};
242+
/// use dir_structure::{error::VfsResult, traits::vfs, error::WrapIoError, prelude::*};
243243
///
244244
/// // !collapse(1:4) collapsed
245245
/// struct FsMtime<T> {
@@ -248,8 +248,8 @@
248248
/// }
249249
///
250250
/// // !collapse(1:9) collapsed
251-
/// impl<'vfs, Vfs: vfs::Vfs<'vfs>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
252-
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> Result<Self> {
251+
/// impl<'vfs, Vfs: vfs::Vfs<'vfs, Path=Path>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
252+
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<Self, Vfs> {
253253
/// let mtime = path.metadata()
254254
/// .and_then(|m| m.modified())
255255
/// .wrap_io_error_with(path)?;
@@ -259,8 +259,8 @@
259259
/// }
260260
///
261261
/// // !collapse(1:9)
262-
/// impl<'vfs, Vfs: vfs::WriteSupportingVfs<'vfs>, T: WriteTo<'vfs, Vfs>> WriteTo<'vfs, Vfs> for FsMtime<T> {
263-
/// fn write_to(&self, path: &Path, vfs: Pin<&'vfs Vfs>) -> Result<()> {
262+
/// impl<'vfs, Vfs: vfs::WriteSupportingVfs<'vfs, Path=Path>, T: WriteTo<'vfs, Vfs>> WriteTo<'vfs, Vfs> for FsMtime<T> {
263+
/// fn write_to(&self, path: &Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<(), Vfs> {
264264
/// self.value.write_to(path, vfs)?;
265265
/// // !mark(1:3)
266266
/// std::fs::File::open(path)
@@ -285,7 +285,7 @@
285285
/// use std::pin::Pin;
286286
/// use std::time::SystemTime;
287287
///
288-
/// use dir_structure::{DirStructure, traits::sync::DirStructureItem, error::Result, traits::vfs, error::WrapIoError, prelude::*};
288+
/// use dir_structure::{DirStructure, traits::sync::DirStructureItem, error::VfsResult, traits::vfs, error::WrapIoError, prelude::*};
289289
///
290290
/// // !collapse(1:4)
291291
/// struct FsMtime<T> {
@@ -294,8 +294,8 @@
294294
/// }
295295
///
296296
/// // !collapse(1:9)
297-
/// impl<'vfs, Vfs: vfs::Vfs<'vfs>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
298-
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> Result<Self> {
297+
/// impl<'vfs, Vfs: vfs::Vfs<'vfs, Path=Path>, T: ReadFrom<'vfs, Vfs>> ReadFrom<'vfs, Vfs> for FsMtime<T> {
298+
/// fn read_from(path: &Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<Self, Vfs> {
299299
/// let mtime = path.metadata()
300300
/// .and_then(|m| m.modified())
301301
/// .wrap_io_error_with(path)?;
@@ -305,8 +305,8 @@
305305
/// }
306306
///
307307
/// // !collapse(1:9)
308-
/// impl<'vfs, Vfs: vfs::WriteSupportingVfs<'vfs>, T: WriteTo<'vfs, Vfs>> WriteTo<'vfs, Vfs> for FsMtime<T> {
309-
/// fn write_to(&self, path: &Path, vfs: Pin<&'vfs Vfs>) -> Result<()> {
308+
/// impl<'vfs, Vfs: vfs::WriteSupportingVfs<'vfs, Path=Path>, T: WriteTo<'vfs, Vfs>> WriteTo<'vfs, Vfs> for FsMtime<T> {
309+
/// fn write_to(&self, path: &Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<(), Vfs> {
310310
/// self.value.write_to(path, vfs)?;
311311
/// std::fs::File::open(path)
312312
/// .and_then(|f| f.set_modified(self.mtime))
@@ -318,16 +318,17 @@
318318
/// // !mark(1:9)
319319
/// // !collapse(1:5)
320320
/// #[derive(DirStructure)]
321-
/// struct Dir {
321+
/// struct Dir<Vfs: vfs::VfsCore<Path=Path>> {
322322
/// #[dir_structure(path = "file.txt")]
323323
/// file: FsMtime<String>,
324+
/// __marker: std::marker::PhantomData<Vfs>,
324325
/// }
325326
///
326327
/// let path = "dir";
327328
/// let mut dir = Dir::read(path)?;
328329
/// dir.file.mtime = SystemTime::UNIX_EPOCH;
329330
/// dir.write(path)?;
330-
/// Ok::<_, dir_structure::error::Error>(())
331+
/// Ok::<_, dir_structure::error::Error::<std::path::PathBuf>>(())
331332
///
332333
/// ```
333334
///

0 commit comments

Comments
 (0)