Files
Oxicloud/src/application/ports/inbound.rs
T

65 lines
2.2 KiB
Rust
Raw Normal View History

2025-03-19 00:44:27 +01:00
use async_trait::async_trait;
2026-02-14 01:29:34 +01:00
use crate::application::dtos::folder_dto::{
CreateFolderDto, FolderDto, MoveFolderDto, RenameFolderDto,
};
2025-03-27 01:13:34 +01:00
use crate::application::dtos::search_dto::{SearchCriteriaDto, SearchResultsDto};
2025-03-19 00:44:27 +01:00
use crate::common::errors::DomainError;
/// Primary port for folder operations
2025-03-19 00:44:27 +01:00
#[async_trait]
pub trait FolderUseCase: Send + Sync + 'static {
/// Creates a new folder
2025-03-19 00:44:27 +01:00
async fn create_folder(&self, dto: CreateFolderDto) -> Result<FolderDto, DomainError>;
2026-02-14 01:29:34 +01:00
/// Gets a folder by its ID
2025-03-19 00:44:27 +01:00
async fn get_folder(&self, id: &str) -> Result<FolderDto, DomainError>;
2026-02-14 01:29:34 +01:00
/// Gets a folder by its path
2025-03-19 00:44:27 +01:00
async fn get_folder_by_path(&self, path: &str) -> Result<FolderDto, DomainError>;
2026-02-14 01:29:34 +01:00
/// Lists folders within a parent folder
2025-03-19 00:44:27 +01:00
async fn list_folders(&self, parent_id: Option<&str>) -> Result<Vec<FolderDto>, DomainError>;
2026-02-14 01:29:34 +01:00
/// Lists folders with pagination
2025-03-19 00:44:27 +01:00
async fn list_folders_paginated(
2026-02-14 01:29:34 +01:00
&self,
2025-03-19 00:44:27 +01:00
parent_id: Option<&str>,
2026-02-14 01:29:34 +01:00
pagination: &crate::application::dtos::pagination::PaginationRequestDto,
2025-03-19 00:44:27 +01:00
) -> Result<crate::application::dtos::pagination::PaginatedResponseDto<FolderDto>, DomainError>;
2026-02-14 01:29:34 +01:00
/// Renames a folder
2026-02-14 01:29:34 +01:00
async fn rename_folder(&self, id: &str, dto: RenameFolderDto)
-> Result<FolderDto, DomainError>;
/// Moves a folder to another parent
2025-03-19 00:44:27 +01:00
async fn move_folder(&self, id: &str, dto: MoveFolderDto) -> Result<FolderDto, DomainError>;
2026-02-14 01:29:34 +01:00
/// Deletes a folder
2025-03-19 00:44:27 +01:00
async fn delete_folder(&self, id: &str) -> Result<(), DomainError>;
}
2025-03-27 01:13:34 +01:00
/**
* Primary port for file and folder search
2026-02-14 01:29:34 +01:00
*
* Defines the operations related to advanced search of
* files and folders based on various criteria.
2025-03-27 01:13:34 +01:00
*/
#[async_trait]
pub trait SearchUseCase: Send + Sync + 'static {
/**
* Performs a search based on the specified criteria
2026-02-14 01:29:34 +01:00
*
* @param criteria Search criteria including text, dates, sizes, etc.
* @return Search results containing matching files and folders
2025-03-27 01:13:34 +01:00
*/
async fn search(&self, criteria: SearchCriteriaDto) -> Result<SearchResultsDto, DomainError>;
2026-02-14 01:29:34 +01:00
2025-03-27 01:13:34 +01:00
/**
* Clears the search results cache
2026-02-14 01:29:34 +01:00
*
* @return Result indicating success or error
2025-03-27 01:13:34 +01:00
*/
async fn clear_search_cache(&self) -> Result<(), DomainError>;
2026-02-14 01:29:34 +01:00
}