Render the name and the uploaded date for each file in the gallery #80

Merged
savanni merged 4 commits from file-service/show-file-metadata into main 2023-10-25 14:36:00 +00:00
2 changed files with 5 additions and 10 deletions
Showing only changes of commit 66876e41c0 - Show all commits

View File

@ -244,7 +244,7 @@ mod test {
let tmp = TempDir::new("var").unwrap();
let handle =
FileHandle::new("rawr.png".to_owned(), PathBuf::from(tmp.path())).expect("to succeed");
assert_eq!(handle.info.name, Some("rawr".to_owned()));
assert_eq!(handle.info.name, "rawr");
assert_eq!(handle.info.size, 0);
assert_eq!(handle.info.file_type, "image/png");
assert_eq!(handle.info.extension, "png");

View File

@ -9,18 +9,13 @@ use std::{
rc::Rc,
};
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Default)]
pub enum Tree<T> {
#[default]
Empty,
Root(Node<T>),
}
impl<T> Default for Tree<T> {
fn default() -> Self {
Tree::Empty
}
}
impl<T> Tree<T> {
pub fn new(value: T) -> (Tree<T>, Node<T>) {
let node = Node::new(value);
@ -129,14 +124,14 @@ impl<T> Node<T> {
}
/// Immutably retrieve the data in this node.
pub fn value<'a>(&self) -> Ref<T> {
pub fn value(&self) -> Ref<T> {
// Ref::map is not actually a member function. I don't know why this was done, other than
// maybe to avoid conflicting with other `map` declarations. Why that is necessary when
// Option::map exists as a member, I don't know.
Ref::map(self.0.borrow(), |v| &v.value)
}
pub fn children<'a>(&self) -> Ref<Vec<Node<T>>> {
pub fn children(&self) -> Ref<Vec<Node<T>>> {
Ref::map(self.0.borrow(), |v| &v.children)
}