Search
This commit is contained in:
50
src/types.rs
Normal file
50
src/types.rs
Normal file
@@ -0,0 +1,50 @@
|
||||
use serde::Deserialize;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Root {
|
||||
pub results: Vec<FileEntry>,
|
||||
pub metadata: Metadata,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct FileEntry {
|
||||
pub name: String,
|
||||
pub ext: String,
|
||||
#[allow(dead_code)]
|
||||
pub path: String,
|
||||
pub url: String,
|
||||
pub size: i64,
|
||||
pub preview: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Metadata {
|
||||
pub page: usize,
|
||||
pub total_pages: usize,
|
||||
pub page_size: usize
|
||||
}
|
||||
|
||||
pub struct SearchContext {
|
||||
pub is_searching: bool,
|
||||
pub search_rx: Option<mpsc::Receiver<Result<(Vec<FileEntry>, Metadata), String>>>,
|
||||
pub search_results: Vec<FileEntry>,
|
||||
pub page: usize,
|
||||
pub per_page : usize,
|
||||
pub total_pages: usize,
|
||||
pub total_results: usize,
|
||||
}
|
||||
|
||||
impl Default for SearchContext {
|
||||
fn default() -> Self {
|
||||
SearchContext {
|
||||
is_searching: false,
|
||||
search_rx: None,
|
||||
search_results: vec![],
|
||||
page: 1,
|
||||
per_page: 25,
|
||||
total_pages: 0,
|
||||
total_results: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user