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
use interface::FieldValue;
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Arc;
use menmos_client::Client;
pub type ClientRC = Arc<Client>;
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct FileMetadata {
pub fields: HashMap<String, FieldValue>,
pub tags: Vec<String>,
}
impl FileMetadata {
pub fn new<S: Into<String>>(name: S) -> Self {
let mut fields: HashMap<String, FieldValue> = HashMap::new();
fields.insert("name".into(), FieldValue::Str(name.into()));
Self {
fields,
..Default::default()
}
}
#[must_use]
pub fn with_tag<S: Into<String>>(mut self, tag: S) -> Self {
self.tags.push(tag.into());
self
}
#[must_use]
pub fn with_field<K: Into<String>, V: Into<FieldValue>>(mut self, key: K, value: V) -> Self {
self.fields.insert(key.into(), value.into());
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct UploadRequest {
pub path: PathBuf,
pub fields: HashMap<String, String>,
pub tags: Vec<String>,
}