rust_filesearch/models/
mod.rs1mod entry;
3pub use entry::{Entry, EntryKind};
4
5#[cfg(feature = "watch")]
6pub use entry::WatchEvent;
7
8mod match_result;
10pub use match_result::ContentMatch;
11
12mod duplicate;
14pub use duplicate::DuplicateGroup;
15
16#[cfg(feature = "git")]
18mod git_status;
19#[cfg(feature = "git")]
20pub use git_status::{GitEntry, GitStatus};
21
22mod category;
24pub use category::{FileCategory, MediaType};
25
26use serde::{Deserialize, Serialize};
28
29#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
31#[serde(rename_all = "lowercase")]
32pub enum SortKey {
33 Name,
34 Size,
35 Mtime,
36 Kind,
37}
38
39#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
41#[serde(rename_all = "lowercase")]
42pub enum SortOrder {
43 Asc,
44 Desc,
45}
46
47#[derive(Debug, Clone, Copy, PartialEq, Eq)]
49pub enum Column {
50 Path,
51 Name,
52 Size,
53 Mtime,
54 Kind,
55 Perms,
56 Owner,
57}
58
59impl Column {
60 #[allow(clippy::should_implement_trait)]
61 pub fn from_str(s: &str) -> Option<Self> {
62 match s.to_lowercase().as_str() {
63 "path" => Some(Column::Path),
64 "name" => Some(Column::Name),
65 "size" => Some(Column::Size),
66 "mtime" => Some(Column::Mtime),
67 "kind" => Some(Column::Kind),
68 "perms" => Some(Column::Perms),
69 "owner" => Some(Column::Owner),
70 _ => None,
71 }
72 }
73}
74
75#[derive(Debug, Clone, Copy, PartialEq, Eq)]
77pub enum OutputFormat {
78 Pretty,
79 Json,
80 Ndjson,
81 Csv,
82}
83
84impl OutputFormat {
85 #[allow(clippy::should_implement_trait)]
86 pub fn from_str(s: &str) -> Option<Self> {
87 match s.to_lowercase().as_str() {
88 "pretty" => Some(OutputFormat::Pretty),
89 "json" => Some(OutputFormat::Json),
90 "ndjson" => Some(OutputFormat::Ndjson),
91 "csv" => Some(OutputFormat::Csv),
92 _ => None,
93 }
94 }
95}