From 9499c97ce65e4b5f8beefc73bc73b7c0b9fc6c2b Mon Sep 17 00:00:00 2001 From: prplV Date: Wed, 5 Mar 2025 12:52:16 +0300 Subject: [PATCH] added config doc-comments --- crates/api-grub/src/config.rs | 63 ++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/crates/api-grub/src/config.rs b/crates/api-grub/src/config.rs index 2d8c835..c0daf03 100644 --- a/crates/api-grub/src/config.rs +++ b/crates/api-grub/src/config.rs @@ -15,6 +15,20 @@ const CONFIG_PATH: &str = "config_api.json"; const SOCKET_PATH: &str = "api-grub.sock"; // TODO: rewrite to use current_exe +/// # Fn `pull_local_config` +/// +/// ## function to one-time pulling local config by straight reading +/// +/// ### Dev-Info : +/// +/// *input* : - +/// +/// *output* : `anyhow::Result` +/// +/// *initiator* : fn `main` +/// +/// *managing* : - +/// pub async fn pull_local_config() -> Result { let path = Path::new(CONFIG_PATH); if path.exists() && path.is_file() { @@ -28,6 +42,22 @@ pub async fn pull_local_config() -> Result { } // for config pulling +/// # Fn `pull_local_config` +/// +/// ## function to init Unix-Socket listening for grabbing new configs +/// +/// ### Dev-Info : +/// +/// *input* : `&tokio::sync::mpsc::Sender` +/// +/// *output* : `anyhow::Result<()>` +/// +/// *initiator* : fn `main` +/// +/// *managing* : - +/// +/// *depends on* : `const SOCKET_PATH` +/// pub async fn init_config_grub_mechanism(tx: &Sender) -> Result<()> { info!("Initializing Unix-Socket listening for pulling new configs..."); let server = init_unix_listener().await?; @@ -57,12 +87,43 @@ pub async fn init_config_grub_mechanism(tx: &Sender) -> Result<()> { } // saving new config locally +/// # Fn `save_new_config` +/// +/// ## function for saving new config locally +/// +/// ### Dev-Info : +/// +/// *input* : `&String | &str` +/// +/// *output* : `anyhow::Result<()>` +/// +/// *initiator* : fn `main` +/// +/// *managing* : - +/// +/// *depends on* : `const CONFIG_PATH` +/// async fn save_new_config(config: &String) -> Result<()> { fs::write(CONFIG_PATH, config)?; Ok(()) } - +/// # Fn `pull_local_config` +/// +/// ## function for saving new config locally +/// +/// ### Dev-Info : +/// +/// *input* : `&tokio::sync::mpsc::Sender` +/// +/// *output* : `anyhow::Result` +/// +/// *initiator* : fn `init_config_grub_mechanism` +/// +/// *managing* : - +/// +/// *depends on* : `const SOCKET_PATH` +/// async fn init_unix_listener() -> Result { let _ = fs::remove_file(SOCKET_PATH); Ok(UnixListener::bind(SOCKET_PATH)?)