1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
use crate::api_core::common::FileMetadataInfo; use crate::api_core::Endpoint; pub mod file_sort_type { pub const SORT_FILE_SIZE: u8 = 0; pub const SORT_FILE_DURATION: u8 = 1; pub const SORT_FILE_IMPORT_TIME: u8 = 2; pub const SORT_FILE_TYPE: u8 = 3; pub const SORT_FILE_RANDOM: u8 = 4; pub const SORT_FILE_WIDTH: u8 = 5; pub const SORT_FILE_HEIGHT: u8 = 6; pub const SORT_FILE_RATIO: u8 = 7; pub const SORT_FILE_PIXEL_COUNT: u8 = 8; pub const SORT_FILE_TAG_COUNT: u8 = 9; pub const SORT_FILE_MEDIA_VIEWS: u8 = 10; pub const SORT_FILE_MEDIA_VIEWTIME: u8 = 11; pub const SORT_FILE_BITRATE: u8 = 12; pub const SORT_FILE_HAS_AUDIO: u8 = 13; pub const SORT_FILE_MODIFIED_TIME: u8 = 14; pub const SORT_FILE_FRAMERATE: u8 = 15; pub const SORT_FILE_FRAME_COUNT: u8 = 16; } #[derive(Clone, Debug, Default)] pub struct FileSearchOptions { file_service_name: Option<String>, file_service_key: Option<String>, tag_service_name: Option<String>, tag_service_key: Option<String>, file_sort_type: Option<u8>, file_sort_asc: Option<bool>, } impl FileSearchOptions { pub fn new() -> Self { Self::default() } pub fn file_service_name<S: ToString>(mut self, name: S) -> Self { self.file_service_name = Some(name.to_string()); self } pub fn file_service_key<S: ToString>(mut self, key: S) -> Self { self.file_service_key = Some(key.to_string()); self } pub fn tag_service_name<S: ToString>(mut self, name: S) -> Self { self.tag_service_name = Some(name.to_string()); self } pub fn tag_service_key<S: ToString>(mut self, key: S) -> Self { self.tag_service_key = Some(key.to_string()); self } pub fn sort_type(mut self, sort_type: u8) -> Self { self.file_sort_type = Some(sort_type); self } pub fn asc(mut self) -> Self { self.file_sort_asc = Some(true); self } pub fn desc(mut self) -> Self { self.file_sort_asc = Some(false); self } pub(crate) fn into_query_args(self) -> Vec<(&'static str, String)> { let mut args = Vec::new(); if let Some(sort) = self.file_sort_type { args.push(("file_sort_type", sort.to_string())); } if let Some(file_service_name) = self.file_service_name { args.push(("file_service_name", file_service_name)); } if let Some(file_service_key) = self.file_service_key { args.push(("file_service_key", file_service_key)); } if let Some(tag_service_name) = self.tag_service_name { args.push(("tag_service_name", tag_service_name)) } if let Some(tag_service_key) = self.tag_service_key { args.push(("tag_service_key", tag_service_key)); } if let Some(sort_asc) = self.file_sort_asc { args.push(("file_sort_asc", sort_asc.to_string())) } args } } #[derive(Debug, Clone, Deserialize)] pub struct SearchFilesResponse { pub file_ids: Vec<u64>, } pub struct SearchFiles; impl Endpoint for SearchFiles { type Request = (); type Response = SearchFilesResponse; fn path() -> String { String::from("get_files/search_files") } } #[derive(Clone, Debug, Default, Deserialize)] pub struct FileMetadataResponse { pub metadata: Vec<FileMetadataInfo>, } pub struct FileMetadata; impl Endpoint for FileMetadata { type Request = (); type Response = FileMetadataResponse; fn path() -> String { String::from("get_files/file_metadata") } } pub struct GetFile; impl Endpoint for GetFile { type Request = (); type Response = (); fn path() -> String { String::from("get_files/file") } }