Phase 5: WebDAV async integration design framework
Some checks failed
Test / build (push) Has been cancelled
Test / test (push) Has been cancelled

- Detailed design notes for AsyncVfsDavFs
- AsyncVfsDavFile implementation pattern
- DavFileSystem trait async implementation
- Estimated: ~3 hours for full implementation

Phase 5 framework documented for future implementation
This commit is contained in:
Warren
2026-06-21 21:20:47 +08:00
parent 94a7584e64
commit 23e0996b81

View File

@@ -625,3 +625,55 @@ pub trait AsyncVfsBackend: Send + Sync {
// - WebDAV integration: 3 hours
// - Tests: 2 hours
// Total: ~13 hours (multi-day project)
//
// ===== Phase 5 WebDAV Async Integration Design =====
//
// 现状分析:
// 1. dav-server DavFileSystem trait 方法返回 Pin<Box<dyn Future>>
// 2. 当前 VfsDavFs::open() 返回 Box::pin(ready(...))
// 3. 这是 "同步包装为 Future",不是真正的 async
//
// Phase 5 目标:
// 1. AsyncVfsDavFs 使用 AsyncVfsBackend
// 2. open() 调用 AsyncVfsBackend::open_file().await
// 3. read_dir() 调用 AsyncVfsBackend::read_dir().await
//
// 实现步骤:
// 1. 创建 AsyncVfsDavFs 结构体
// 2. 创建 AsyncVfsDavFile 结构体(包装 AsyncVfsFile
// 3. 实现 DavFileSystem trait调用 AsyncVfsBackend
//
// 关键代码模式:
// ```rust
// impl DavFileSystem for AsyncVfsDavFs {
// fn open<'a>(&'a self, path: &'a DavPath, options: OpenOptions) -> FsFuture<'a, Box<dyn DavFile>> {
// Box::pin(async move {
// let vfs_path = self.resolve_path(path)?;
// let flags = OpenFlags::from_open_options(&options);
// let file = AsyncVfsBackend::open_file(&*self.vfs, &vfs_path, &flags).await?;
// Ok(Box::new(AsyncVfsDavFile::new(file)) as Box<dyn DavFile>)
// })
// }
// }
// ```
//
// AsyncVfsDavFile 实现:
// ```rust
// pub struct AsyncVfsDavFile {
// inner: Box<dyn AsyncVfsFile>,
// position: u64,
// }
//
// impl DavFile for AsyncVfsDavFile {
// fn read_bytes(&mut self, count: usize) -> FsFuture<'_, Bytes> {
// Box::pin(async move {
// let mut buf = vec![0u8; count];
// let n = AsyncVfsFile::read(&mut self.inner, &mut buf).await?;
// buf.truncate(n);
// Ok(Bytes::from(buf))
// })
// }
// }
// ```
//
// 预估工作量Phase 5 ~3 hours