From d58f140a29ce6fc1b385202cceff23969d0825e0 Mon Sep 17 00:00:00 2001 From: prplV Date: Wed, 13 Nov 2024 14:42:31 +0300 Subject: [PATCH] docs: files --- src/utils/files.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/utils/files.rs b/src/utils/files.rs index 4221da9..6293c7b 100644 --- a/src/utils/files.rs +++ b/src/utils/files.rs @@ -7,6 +7,19 @@ use std::sync::Arc; use tokio::sync::mpsc; use tokio::time::Duration; +/// # Fn `create_watcher` +/// ## for creating watcher on file's delete | update events +/// +/// *input* : `&str`, `&str` +/// +/// *output* : `Err` if it cant create file watcher | `Ok(watcher)` on successfull construction +/// +/// *initiator* : fn `file_handler`, fn `utils::run_daemons` +/// +/// *managing* : current file's name: &str, path in local storage to current file: &str +/// +/// *depends on* : - +/// pub async fn create_watcher(filename: &str, path: &str) -> Result { let src = format!("{}{}", path, filename); let inotify: Inotify = Inotify::init()?; @@ -14,6 +27,19 @@ pub async fn create_watcher(filename: &str, path: &str) -> Result>`, `Arc>>` +/// +/// *output* : `Err` if something with dep file is wrong | `Ok(())` on successfull dep file check +/// +/// *initiator* : fn `utils::running_handler` +/// +/// *managing* : current process's name: &str, list of dep files : `&[Files]`, atomic ref counter on sender main channel for current process `Arc>`, mut list of file watchers`Arc>>` +/// +/// *depends on* : Files +/// pub async fn file_handler( name: &str, files: &[Files], @@ -97,6 +123,19 @@ pub async fn file_handler( Ok(()) } +/// # Fn `check_file` +/// ## for checking existance of current file +/// +/// *input* : `&str`, `&str` +/// +/// *output* : `Ok(())` if file exists | `Err(_)` if not | panic on fs error +/// +/// *initiator* : fn `file_handler` +/// +/// *managing* : current file's name: `&str` and current file's path in local storage: `&str` +/// +/// *depends on* : network activity +/// pub async fn check_file(filename: &str, path: &str) -> Result<(), CustomError> { let arc_name = Arc::new(filename.to_string()); let arc_path = Arc::new(path.to_string());