aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-23 13:51:20 +0000
committerFuwn <[email protected]>2021-05-23 13:51:20 +0000
commit59cd17d4b5b1eff2847a954012eb916db4ef5116 (patch)
tree4074d9935949a48c64fdaa8503ae9ddc61e7678e
parentbuild(cargo): create a fast builds configuration for cargo (diff)
downloadwhirl-59cd17d4b5b1eff2847a954012eb916db4ef5116.tar.xz
whirl-59cd17d4b5b1eff2847a954012eb916db4ef5116.zip
docs(global): add new documentation
-rw-r--r--crates/whirl_api/src/lib.rs1
-rw-r--r--crates/whirl_common/src/log.rs2
-rw-r--r--crates/whirl_common/src/sort.rs2
-rw-r--r--crates/whirl_common/src/system.rs1
-rw-r--r--crates/whirl_config/src/lib.rs2
-rw-r--r--crates/whirl_server/src/cmd/set_parser.rs4
-rw-r--r--crates/whirl_server/src/net/property_parser.rs4
-rw-r--r--crates/whirl_server/src/packet_parser.rs6
8 files changed, 15 insertions, 7 deletions
diff --git a/crates/whirl_api/src/lib.rs b/crates/whirl_api/src/lib.rs
index e77e7d3..0b24953 100644
--- a/crates/whirl_api/src/lib.rs
+++ b/crates/whirl_api/src/lib.rs
@@ -22,6 +22,7 @@ mod routes;
pub struct Api;
impl Api {
+ /// Begin handling connections on the web-server.
pub async fn listen(
tx: std::sync::mpsc::Sender<actix_web::dev::Server>,
address: &str,
diff --git a/crates/whirl_common/src/log.rs b/crates/whirl_common/src/log.rs
index 39ceca0..e905bc8 100644
--- a/crates/whirl_common/src/log.rs
+++ b/crates/whirl_common/src/log.rs
@@ -3,6 +3,8 @@
use whirl_config::Config;
+/// Grab the log level configuration key (`whirlsplash.log.level`) from the
+/// configuration file and evaluate the proper log level.
pub fn calculate_log_level() -> String {
let mut level;
diff --git a/crates/whirl_common/src/sort.rs b/crates/whirl_common/src/sort.rs
index 131fa55..b1b79b2 100644
--- a/crates/whirl_common/src/sort.rs
+++ b/crates/whirl_common/src/sort.rs
@@ -1,6 +1,8 @@
// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective
// SPDX-License-Identifier: GPL-3.0-only
+/// Sort a vector by alphabetical order based on the first character of each
+/// string.
pub fn sort_vec_alphabetically(vec: &mut Vec<&str>) {
vec.sort_by(|a, b| a.to_lowercase().cmp(&b.to_lowercase()));
}
diff --git a/crates/whirl_common/src/system.rs b/crates/whirl_common/src/system.rs
index 7a823a0..3b4806b 100644
--- a/crates/whirl_common/src/system.rs
+++ b/crates/whirl_common/src/system.rs
@@ -16,6 +16,7 @@ fn make_parts(t: usize, steps: &[usize], mut accum: Vec<usize>) -> Vec<usize> {
}
}
+/// Convert a Unix (Epoch) Timestamp to a human-readable format.
pub fn seconds_to_hrtime(seconds: usize) -> String {
let word = ["week", "day", "hour", "min", "sec"];
diff --git a/crates/whirl_config/src/lib.rs b/crates/whirl_config/src/lib.rs
index 8f312cd..66d3a26 100644
--- a/crates/whirl_config/src/lib.rs
+++ b/crates/whirl_config/src/lib.rs
@@ -36,6 +36,7 @@ pub struct Config {
pub hub: HubConfig,
}
impl Config {
+ /// Re-fetch the configuration from the configuration file.
pub fn refresh() { let _ = config::Config::new().refresh(); }
fn load() -> Result<Self, ConfigError> {
@@ -45,6 +46,7 @@ impl Config {
s.try_into()
}
+ // Get a certain configuration key or group from the configuration file.
pub fn get() -> Config {
return if let Err(why) = Self::load() {
error!(
diff --git a/crates/whirl_server/src/cmd/set_parser.rs b/crates/whirl_server/src/cmd/set_parser.rs
index 9d6a4b3..600badd 100644
--- a/crates/whirl_server/src/cmd/set_parser.rs
+++ b/crates/whirl_server/src/cmd/set_parser.rs
@@ -3,8 +3,8 @@
use crate::cmd::structure::Command;
-/// Iterate over a command set in the from of bytes and return a list of
-/// human-readable commands.
+/// Iterate over a command set in the from of bytes (Vec<u8>) and return a list
+/// of human-readable commands.
fn _parse_command_set(mut data: Vec<u8>) -> Vec<Command> {
let mut command_set = vec![];
diff --git a/crates/whirl_server/src/net/property_parser.rs b/crates/whirl_server/src/net/property_parser.rs
index f86b767..bce457d 100644
--- a/crates/whirl_server/src/net/property_parser.rs
+++ b/crates/whirl_server/src/net/property_parser.rs
@@ -5,8 +5,8 @@ use std::str::from_utf8;
use crate::net::structure::NetworkProperty;
-/// Iterate over a network property in the form of bytes and return a list of
-/// human-readable properties.
+/// Iterate over a network property in the form of bytes (Vec<u8>) and return a
+/// list of human-readable properties.
pub fn parse_network_property(mut data: Vec<u8>) -> Vec<NetworkProperty> {
let mut property_list = vec![];
diff --git a/crates/whirl_server/src/packet_parser.rs b/crates/whirl_server/src/packet_parser.rs
index bfeba9e..79293cb 100644
--- a/crates/whirl_server/src/packet_parser.rs
+++ b/crates/whirl_server/src/packet_parser.rs
@@ -3,13 +3,13 @@
use bytes::BytesMut;
-/// Read all commands from the given buffer.
+/// Read all commands from the given `buffer`.
///
/// # Process
-/// 1. Get a command from `buffer` based on first byte.
+/// 1. Read a command from `buffer` based on it's first byte.
/// 2. Push command to `commands`.
/// 3. Remove command from `buffer`.
-/// 4. Iterate and do this for all commands within `buffer`.
+/// 4. Iterate and do this for the remaining commands within `buffer`.
pub fn parse_commands_from_packet(mut buffer: BytesMut) -> Vec<BytesMut> {
let mut commands: Vec<BytesMut> = Vec::new();
trace!("initial buffer: {:?}, length: {}", buffer, buffer.len());