summaryrefslogtreecommitdiffstats
path: root/src/models/model.rs
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-09-20 13:53:16 +0000
committerSanto Cariotti <santo@dcariotti.me>2022-09-20 13:53:16 +0000
commit7287390e0398570961fd998652bd180d6fb13b78 (patch)
treee4d5e091ac781a31683fc1dc0c936d82650a6c29 /src/models/model.rs
parent224b7e52c7a7a02d36a82c070925a2e506b7b2f4 (diff)
Run clippy + add doc
Diffstat (limited to 'src/models/model.rs')
-rw-r--r--src/models/model.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/models/model.rs b/src/models/model.rs
index 80eb5ad..6b7c166 100644
--- a/src/models/model.rs
+++ b/src/models/model.rs
@@ -194,6 +194,7 @@ impl Model {
}
impl ModelUser {
+ /// Returns the author id from the `JsonValue`
pub fn author_id(&self) -> JsonValue {
match &self.author {
Some(json) => json.get("id").unwrap().clone(),
@@ -201,10 +202,10 @@ impl ModelUser {
}
}
- pub async fn upload_paths(&self) -> Option<Vec<String>> {
- if self.uploads.is_none() {
- return None;
- }
+ /// Returns a vec of string made by all the filepaths from the model
+ pub async fn list_upload_filepaths(&self) -> Option<Vec<String>> {
+ // Raise a `None` if `self.uploads` is `None`
+ self.uploads.as_ref()?;
let uploads = ModelUpload::find_by_model(self.id)
.await
@@ -215,7 +216,7 @@ impl ModelUser {
.map(|x| x.filepath.clone())
.collect::<Vec<String>>();
- return Some(paths);
+ Some(paths)
}
}