Skip to content

Commit cdfe9bb

Browse files
author
Illyrius
committed
fix docs
Signed-off-by: Illyrius <fitimq@live.nl>
1 parent 96ac634 commit cdfe9bb

1 file changed

Lines changed: 0 additions & 74 deletions

File tree

src/config.rs

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,8 @@ use std::{fs, io};
1010
/// the `PlayerModuleConfig` configuration.
1111
///
1212
/// # Attributes
13-
///
1413
/// * `player_module` - A public field of type `PlayerModuleConfig` that holds
1514
/// the configuration details for the player module.
16-
///
17-
/// # Derives
18-
///
19-
/// This struct derives the following traits:
20-
/// - `Clone`: Enables the `ConfigManager` to be cloned.
21-
/// - `Debug`: Provides the ability to format the `ConfigManager` for debugging purposes.
22-
/// - `Default`: Allows the creation of a default instance of `ConfigManager`.
23-
/// - `Serialize`: Enables serialization of the `ConfigManager` into formats such as JSON.
24-
/// - `Deserialize`: Allows deserialization of the `ConfigManager` from formats such as JSON.
25-
///
26-
/// # Example
27-
/// ```
28-
/// use your_crate_name::ConfigManager;
29-
///
30-
/// let default_config = ConfigManager::default();
31-
/// println!("{:?}", default_config);
32-
/// ```
3315
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
3416
pub struct ConfigManager {
3517
pub player_module: Config,
@@ -38,34 +20,14 @@ pub struct ConfigManager {
3820
impl ConfigManager {
3921
/// Creates a new instance of the configuration.
4022
///
41-
/// This function attempts to load an existing configuration file from the path
42-
/// determined by the `path` function. If the file does not exist, it creates a
43-
/// default configuration, saves it at the specified path, and returns the default configuration.
44-
///
4523
/// # Arguments
46-
///
4724
/// * `ctx` - An `Arc<Context>` instance, which provides the necessary context
4825
/// to determine the file path for the configuration.
4926
///
5027
/// # Returns
51-
///
5228
/// * `Ok(Self)` - If the configuration is successfully loaded or created as default.
5329
/// * `Err(io::Error)` - If an I/O error occurs during the loading or saving process,
5430
/// other than a `NotFound` error.
55-
///
56-
/// # Errors
57-
///
58-
/// * Returns an error if:
59-
/// - Loading the configuration file fails for reasons other than the file being
60-
/// not found.
61-
/// - Saving the default configuration fails.
62-
///
63-
/// # Example
64-
///
65-
/// ```rust
66-
/// let context = Arc::new(Context::new());
67-
/// let config = ConfigManager::new(context).expect("Failed to create configuration");
68-
/// ```
6931
pub fn new(ctx: Arc<Context>) -> Result<Self, io::Error> {
7032
let path = Self::path(ctx.clone());
7133

@@ -82,25 +44,9 @@ impl ConfigManager {
8244

8345
/// Generates the file path for the configuration file.
8446
///
85-
/// This function constructs the full file path to the `config.json` file
86-
/// located in the data folder of the provided context.
87-
///
8847
/// # Arguments
89-
///
9048
/// * `ctx` - An `Arc<Context>` object that provides access to the application's
9149
/// data folder through its `get_data_folder` method.
92-
///
93-
/// # Returns
94-
///
95-
/// A `PathBuf` representing the full path to the `config.json` file.
96-
///
97-
/// # Example
98-
///
99-
/// ```rust
100-
/// let context = Arc::new(Context::new());
101-
/// let config_path = path(context);
102-
/// println!("{:?}", config_path); // Outputs: /path/to/data_folder/config.json
103-
/// ```
10450
fn path(ctx: Arc<Context>) -> PathBuf {
10551
ctx.get_data_folder().join("config.json")
10652
}
@@ -121,7 +67,6 @@ impl ConfigManager {
12167
}
12268

12369
/// Saves the current object to the specified file path in a JSON format.
124-
/// If necessary, creates any parent directories for the file path.
12570
///
12671
/// # Parameters
12772
/// - `path`: A reference to a [`Path`] where the object should be saved.
@@ -130,25 +75,6 @@ impl ConfigManager {
13075
/// - `Result<(), io::Error>`:
13176
/// - `Ok(())` if the object is successfully saved.
13277
/// - An `io::Error` if an error occurs during the serialization or file operations.
133-
///
134-
/// # Errors
135-
/// - Returns an `io::Error` if:
136-
/// - Parent directories cannot be created.
137-
/// - The object cannot be serialized into JSON (e.g., due to invalid data).
138-
/// - The JSON content cannot be written to the file system.
139-
///
140-
/// # Examples
141-
/// ```rust
142-
/// use std::path::Path;
143-
/// use std::fs;
144-
///
145-
/// let my_obj = MyStruct::new();
146-
/// let path = Path::new("output/my_file.json");
147-
///
148-
/// if let Err(e) = my_obj.save(&path) {
149-
/// eprintln!("Failed to save object: {}", e);
150-
/// }
151-
/// ```
15278
fn save(&self, path: &Path) -> Result<(), io::Error> {
15379
if let Some(parent) = path.parent() {
15480
fs::create_dir_all(parent)?;

0 commit comments

Comments
 (0)