docs: Add rustdoc comments for functions, structs, and traits

Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-09-10 10:52:31 -03:00
parent ec4dfed2be
commit 25b99b938e
6 changed files with 415 additions and 60 deletions

View File

@@ -6,6 +6,16 @@ pub struct UserMetaPlugin {
}
impl UserMetaPlugin {
/// Creates a new `UserMetaPlugin` instance.
///
/// # Arguments
///
/// * `options` - Optional configuration options for the plugin.
/// * `outputs` - Optional output mappings for metadata.
///
/// # Returns
///
/// A new instance of `UserMetaPlugin`.
pub fn new(
options: Option<std::collections::HashMap<String, serde_yaml::Value>>,
outputs: Option<std::collections::HashMap<String, serde_yaml::Value>>,
@@ -25,11 +35,21 @@ impl UserMetaPlugin {
}
/// Gets the current username.
///
/// # Returns
///
/// An `Option<String>` with the username, or `None` if unavailable.
fn get_current_username() -> Option<String> {
uzers::get_user_by_uid(uzers::get_current_uid())
.map(|user| user.name().to_string_lossy().to_string())
}
/// Gets the current group name.
///
/// # Returns
///
/// An `Option<String>` with the group name, or `None` if unavailable.
fn get_current_groupname() -> Option<String> {
uzers::get_group_by_gid(uzers::get_current_gid())
.map(|group| group.name().to_string_lossy().to_string())
@@ -37,6 +57,11 @@ impl UserMetaPlugin {
}
impl MetaPlugin for UserMetaPlugin {
/// Initializes the plugin, capturing user information.
///
/// # Returns
///
/// A `MetaPluginResponse` with user metadata and `is_finalized` set to `true`.
fn initialize(&mut self) -> crate::meta_plugin::MetaPluginResponse {
let mut metadata = Vec::new();
@@ -70,27 +95,57 @@ impl MetaPlugin for UserMetaPlugin {
}
}
/// Returns the type of this meta plugin.
///
/// # Returns
///
/// `MetaPluginType::User`.
fn meta_type(&self) -> MetaPluginType {
MetaPluginType::User
}
/// Returns a reference to the outputs mapping.
///
/// # Returns
///
/// A reference to the `HashMap` of outputs.
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
self.base.outputs()
}
/// Returns a mutable reference to the outputs mapping.
///
/// # Returns
///
/// A mutable reference to the `HashMap` of outputs.
fn outputs_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
self.base.outputs_mut()
}
/// Returns the default output names.
///
/// # Returns
///
/// A vector of default output names.
fn default_outputs(&self) -> Vec<String> {
vec!["user_uid".to_string(), "user_gid".to_string(), "user_name".to_string(), "user_group".to_string()]
}
/// Returns a reference to the options mapping.
///
/// # Returns
///
/// A reference to the `HashMap` of options.
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
self.base.options()
}
/// Returns a mutable reference to the options mapping.
///
/// # Returns
///
/// A mutable reference to the `HashMap` of options.
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
self.base.options_mut()
}