use async_trait::async_trait; use musicfs_core::{DirEntry, FileStat, HealthStatus, OriginId, OriginType, Result}; use std::path::{Path, PathBuf}; use tokio::io::AsyncRead; #[async_trait] pub trait Origin: Send + Sync { fn id(&self) -> &OriginId; fn origin_type(&self) -> OriginType; fn display_name(&self) -> &str; async fn readdir(&self, path: &Path) -> Result>; async fn stat(&self, path: &Path) -> Result; async fn read(&self, path: &Path, offset: u64, size: u32) -> Result>; /// Read entire file content (for CDC chunking of files <4GB) async fn read_full(&self, path: &Path) -> Result>; async fn exists(&self, path: &Path) -> Result; async fn health(&self) -> HealthStatus; async fn open_read(&self, path: &Path) -> Result>; async fn watch(&self, path: &Path, callback: WatchCallback) -> Result; } pub type WatchCallback = Box; pub struct WatchHandle { _cancel: tokio::sync::oneshot::Sender<()>, } impl WatchHandle { pub fn new(cancel: tokio::sync::oneshot::Sender<()>) -> Self { Self { _cancel: cancel } } } #[derive(Debug, Clone)] pub enum WatchEvent { Created(PathBuf), Modified(PathBuf), Deleted(PathBuf), }