From 3e2c3341ee4fd540126f822ef23aa442508cf4b6 Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Wed, 13 Feb 2019 19:13:34 +0100 Subject: Added some docstrings --- src/listing.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/listing.rs') diff --git a/src/listing.rs b/src/listing.rs index aeddd7d..f0662ef 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -9,15 +9,28 @@ use std::path::Path; use std::str::FromStr; #[derive(Clone, Copy, Debug)] +/// Available sorting methods pub enum SortingMethods { + /// Natural sorting method + /// 1 -> 2 -> 3 -> 11 Natural, + + /// Pure alphabetical sorting method + /// 1 -> 11 -> 2 -> 3 Alpha, + + /// Directories are listed first, alphabetical sorting is also applied + /// 1/ -> 2/ -> 3/ -> 11 -> 12 DirsFirst, } #[derive(PartialEq)] +/// Possible entry types enum EntryType { + /// Entry is a directory Directory, + + /// Entry is a file File, } @@ -31,10 +44,18 @@ impl PartialOrd for EntryType { } } +/// Entry struct Entry { + /// Name of the entry name: String, + + /// Type of the entry entry_type: EntryType, + + /// URL of the entry link: String, + + /// Size in byte of the entry. Only available for EntryType::File size: Option, } @@ -72,7 +93,8 @@ pub fn file_handler(req: &HttpRequest) -> Result( dir: &fs::Directory, req: &HttpRequest, -- cgit v1.2.3