Finish implementing native filesystem (Legacy) #1

Open
opened 2025-08-21 23:50:21 +01:00 by zxq5 · 0 comments
Owner

First step in making this project platform independent. the next stage will be to switch to a custom file tree with caching.

Todos:

  • Implement all methods from the below trait for NativeFileSystem
    • read
    • read_bytes
    • write
    • delete
    • mkdir
    • rename
    • exists
    • config_path
  • All document types should use this new API
    • Objects and templates
    • Notes and Documents
    • Tags
    • Assets
  • Move the file tree to the new API
  • Error handling
    • trait needs custom error type
    • easy conversions to type
pub trait LegacyFileSystem {
    fn read<T: DeserializeOwned>(&self, path: &Path) -> Result<T, FsError>;
    fn read_bytes(&self, path: &Path) -> Result<Vec<u8>, FsError>;
    fn write<T: Serialize>(&self, path: &Path, data: T) -> Result<(), FsError>;
    fn delete(&self, path: &Path) -> Result<(), FsError>;
    fn mkdir(&self, path: &Path) -> Result<(), FsError>;
    fn rename(&self, path: &Path, new_path: &Path) -> Result<(), FsError>;
    fn exists(&self, path: &Path) -> bool;
    fn config_path(&self) -> PathBuf;
}
First step in making this project platform independent. the next stage will be to switch to a custom file tree with caching. ### Todos: - [x] Implement all methods from the below trait for NativeFileSystem - [x] read - [x] read_bytes - [x] write - [x] delete - [x] mkdir - [x] rename - [x] exists - [x] config_path - [x] All document types should use this new API - [x] Objects and templates - [x] Notes and Documents - [x] Tags - [x] Assets - [x] Move the file tree to the new API - [x] Error handling - [x] trait needs custom error type - [x] easy conversions to type ```rust pub trait LegacyFileSystem { fn read<T: DeserializeOwned>(&self, path: &Path) -> Result<T, FsError>; fn read_bytes(&self, path: &Path) -> Result<Vec<u8>, FsError>; fn write<T: Serialize>(&self, path: &Path, data: T) -> Result<(), FsError>; fn delete(&self, path: &Path) -> Result<(), FsError>; fn mkdir(&self, path: &Path) -> Result<(), FsError>; fn rename(&self, path: &Path, new_path: &Path) -> Result<(), FsError>; fn exists(&self, path: &Path) -> bool; fn config_path(&self) -> PathBuf; } ```
zxq5 added this to the WorldCoder project 2025-08-21 23:50:21 +01:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: zxq5/worldcoder#1