pub mod category;
pub mod management;
pub mod query;
pub use category::{
BtListOptions, Category, CategoryCountOptions, CategorySearchOptions, DocumentListOptions,
ImageListOptions, VideoListOptions,
};
pub use management::{FolderCreateOptions, FolderInfo};
pub use query::{
FileInfo, FileMeta, ListAllOptions, ListOptions, SearchOptions,
SemanticSearchOptions,
};
use category::FileCategoryExt;
use management::FileManagementExt;
use query::FileQueryExt;
use crate::http::HttpClient;
use crate::auth::AccessToken;
use crate::errors::NetDiskResult;
#[derive(Debug, Clone)]
pub struct FileClient {
http_client: HttpClient,
}
impl FileClient {
pub fn new(http_client: HttpClient) -> Self {
FileClient { http_client }
}
pub fn http_client(&self) -> &HttpClient {
&self.http_client
}
pub async fn list_directory(&self, access_token: &AccessToken, dir: &str) -> NetDiskResult<Vec<FileInfo>> {
FileQueryExt::list_directory(self, access_token, dir).await
}
pub async fn list_directory_with_options(&self, access_token: &AccessToken, dir: &str, options: ListOptions) -> NetDiskResult<Vec<FileInfo>> {
FileQueryExt::list_directory_with_options(self, access_token, dir, options).await
}
pub async fn list_all(&self, access_token: &AccessToken, path: &str) -> NetDiskResult<(Vec<FileInfo>, bool)> {
FileQueryExt::list_all(self, access_token, path).await
}
pub async fn list_all_with_options(&self, access_token: &AccessToken, path: &str, options: ListAllOptions) -> NetDiskResult<(Vec<FileInfo>, bool)> {
FileQueryExt::list_all_with_options(self, access_token, path, options).await
}
pub async fn get_file_info(&self, access_token: &AccessToken, path: &str) -> NetDiskResult<FileInfo> {
FileQueryExt::get_file_info(self, access_token, path).await
}
pub async fn get_file_meta(&self, access_token: &AccessToken, fs_id: u64) -> NetDiskResult<FileMeta> {
FileQueryExt::get_file_meta(self, access_token, fs_id).await
}
pub async fn search_files(&self, access_token: &AccessToken, key: &str, dir: &str) -> NetDiskResult<(Vec<FileInfo>, bool)> {
FileQueryExt::search_files(self, access_token, key, dir).await
}
pub async fn search_files_with_options(&self, access_token: &AccessToken, key: &str, options: SearchOptions) -> NetDiskResult<(Vec<FileInfo>, bool)> {
FileQueryExt::search_files_with_options(self, access_token, key, options).await
}
pub async fn semantic_search(&self, access_token: &AccessToken, query: &str) -> NetDiskResult<Vec<FileInfo>> {
FileQueryExt::semantic_search(self, access_token, query).await
}
pub async fn semantic_search_with_options(&self, access_token: &AccessToken, query: &str, options: SemanticSearchOptions) -> NetDiskResult<Vec<FileInfo>> {
FileQueryExt::semantic_search_with_options(self, access_token, query, options).await
}
pub async fn create_folder(&self, access_token: &AccessToken, path: &str) -> NetDiskResult<FolderInfo> {
FileManagementExt::create_folder(self, access_token, path).await
}
pub async fn create_folder_with_options(&self, access_token: &AccessToken, path: &str, options: FolderCreateOptions) -> NetDiskResult<FolderInfo> {
FileManagementExt::create_folder_with_options(self, access_token, path, options).await
}
pub async fn rename(&self, access_token: &AccessToken, path: &str, new_name: &str) -> NetDiskResult<()> {
FileManagementExt::rename(self, access_token, path, new_name).await
}
pub async fn delete(&self, access_token: &AccessToken, path: &str) -> NetDiskResult<()> {
FileManagementExt::delete(self, access_token, path).await
}
pub async fn move_file(&self, access_token: &AccessToken, path: &str, dest: &str) -> NetDiskResult<()> {
FileManagementExt::move_file(self, access_token, path, dest).await
}
pub async fn copy_file(&self, access_token: &AccessToken, path: &str, dest: &str) -> NetDiskResult<()> {
FileManagementExt::copy_file(self, access_token, path, dest).await
}
pub async fn get_category_file_count(&self, access_token: &AccessToken, category: u32) -> NetDiskResult<u64> {
FileCategoryExt::get_category_file_count(self, access_token, category).await
}
pub async fn get_category_file_count_with_options(&self, access_token: &AccessToken, category: u32, options: CategoryCountOptions) -> NetDiskResult<u64> {
FileCategoryExt::get_category_file_count_with_options(self, access_token, category, options).await
}
pub async fn search_category_files(&self, access_token: &AccessToken, category: u32, start: i32, limit: i32) -> NetDiskResult<(Vec<FileInfo>, u64)> {
FileCategoryExt::search_category_files(self, access_token, category, start, limit).await
}
pub async fn search_category_files_with_options(&self, access_token: &AccessToken, category: &str, options: CategorySearchOptions) -> NetDiskResult<(Vec<FileInfo>, u64)> {
FileCategoryExt::search_category_files_with_options(self, access_token, category, options).await
}
pub async fn list_documents(&self, access_token: &AccessToken, parent_path: &str, page: i32, num: i32) -> NetDiskResult<Vec<FileInfo>> {
FileCategoryExt::list_documents(self, access_token, parent_path, page, num).await
}
pub async fn list_documents_with_options(&self, access_token: &AccessToken, options: DocumentListOptions) -> NetDiskResult<Vec<FileInfo>> {
FileCategoryExt::list_documents_with_options(self, access_token, options).await
}
pub async fn list_images(&self, access_token: &AccessToken, parent_path: &str, page: i32, num: i32) -> NetDiskResult<Vec<FileInfo>> {
FileCategoryExt::list_images(self, access_token, parent_path, page, num).await
}
pub async fn list_images_with_options(&self, access_token: &AccessToken, options: ImageListOptions) -> NetDiskResult<Vec<FileInfo>> {
FileCategoryExt::list_images_with_options(self, access_token, options).await
}
pub async fn list_videos(&self, access_token: &AccessToken, parent_path: &str, page: i32, num: i32) -> NetDiskResult<Vec<FileInfo>> {
FileCategoryExt::list_videos(self, access_token, parent_path, page, num).await
}
pub async fn list_videos_with_options(&self, access_token: &AccessToken, options: VideoListOptions) -> NetDiskResult<Vec<FileInfo>> {
FileCategoryExt::list_videos_with_options(self, access_token, options).await
}
pub async fn list_torrents(&self, access_token: &AccessToken, parent_path: &str, page: i32, num: i32) -> NetDiskResult<Vec<FileInfo>> {
FileCategoryExt::list_torrents(self, access_token, parent_path, page, num).await
}
pub async fn list_torrents_with_options(&self, access_token: &AccessToken, options: BtListOptions) -> NetDiskResult<Vec<FileInfo>> {
FileCategoryExt::list_torrents_with_options(self, access_token, options).await
}
}