use async_trait::async_trait; use crate::application::dtos::folder_dto::{ CreateFolderDto, FolderDto, MoveFolderDto, RenameFolderDto, }; use crate::application::dtos::search_dto::{ SearchCriteriaDto, SearchResultsDto, SearchSuggestionsDto, }; use crate::common::errors::DomainError; /// Primary port for folder operations #[async_trait] pub trait FolderUseCase: Send + Sync + 'static { /// Creates a new folder async fn create_folder(&self, dto: CreateFolderDto) -> Result; /// Gets a folder by its ID async fn get_folder(&self, id: &str) -> Result; /// Gets a folder by its path async fn get_folder_by_path(&self, path: &str) -> Result; /// Lists folders within a parent folder async fn list_folders(&self, parent_id: Option<&str>) -> Result, DomainError>; /// Lists folders scoped to a specific owner (for user-facing endpoints). /// At root level, only returns folders belonging to this user. async fn list_folders_for_owner( &self, parent_id: Option<&str>, owner_id: &str, ) -> Result, DomainError>; /// Lists folders with pagination async fn list_folders_paginated( &self, parent_id: Option<&str>, pagination: &crate::application::dtos::pagination::PaginationRequestDto, ) -> Result, DomainError>; /// Renames a folder async fn rename_folder(&self, id: &str, dto: RenameFolderDto) -> Result; /// Moves a folder to another parent async fn move_folder(&self, id: &str, dto: MoveFolderDto) -> Result; /// Deletes a folder async fn delete_folder(&self, id: &str) -> Result<(), DomainError>; } /** * Primary port for file and folder search. * * All search processing (filtering, scoring, sorting, categorization) * is handled server-side in Rust for maximum efficiency. */ #[async_trait] pub trait SearchUseCase: Send + Sync + 'static { /// Performs a full search based on the specified criteria. async fn search(&self, criteria: SearchCriteriaDto) -> Result; /// Returns quick suggestions for autocomplete (lightweight, fast). async fn suggest( &self, query: &str, folder_id: Option<&str>, limit: usize, ) -> Result; /// Clears the search results cache. async fn clear_search_cache(&self) -> Result<(), DomainError>; }