Skip to content

Commit 790e1ec

Browse files
committed
refactor: [torrust#581] rename TorrustIndex to Settings
1 parent 1a28309 commit 790e1ec

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

src/config/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use tokio::sync::RwLock;
1313
use torrust_index_located_error::{Located, LocatedError};
1414
use url::{ParseError, Url};
1515

16-
pub type TorrustIndex = v1::Settings;
16+
pub type Settings = v1::Settings;
1717
pub type Api = v1::api::Api;
1818
pub type Auth = v1::auth::Auth;
1919
pub type Database = v1::database::Database;
@@ -225,13 +225,13 @@ impl Tsl {
225225
#[derive(Debug)]
226226
pub struct Configuration {
227227
/// The state of the configuration.
228-
pub settings: RwLock<TorrustIndex>,
228+
pub settings: RwLock<Settings>,
229229
}
230230

231231
impl Default for Configuration {
232232
fn default() -> Configuration {
233233
Configuration {
234-
settings: RwLock::new(TorrustIndex::default()),
234+
settings: RwLock::new(Settings::default()),
235235
}
236236
}
237237
}
@@ -252,22 +252,22 @@ impl Configuration {
252252
let config_builder = Config::builder()
253253
.add_source(File::from_str(&info.index_toml, FileFormat::Toml))
254254
.build()?;
255-
let mut index_config: TorrustIndex = config_builder.try_deserialize()?;
255+
let mut settings: Settings = config_builder.try_deserialize()?;
256256

257257
if let Some(ref token) = info.tracker_api_token {
258-
index_config.override_tracker_api_token(token);
258+
settings.override_tracker_api_token(token);
259259
};
260260

261261
if let Some(ref secret_key) = info.auth_secret_key {
262-
index_config.override_auth_secret_key(secret_key);
262+
settings.override_auth_secret_key(secret_key);
263263
};
264264

265265
Ok(Configuration {
266-
settings: RwLock::new(index_config),
266+
settings: RwLock::new(settings),
267267
})
268268
}
269269

270-
pub async fn get_all(&self) -> TorrustIndex {
270+
pub async fn get_all(&self) -> Settings {
271271
let settings_lock = self.settings.read().await;
272272

273273
settings_lock.clone()

src/services/settings.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use std::sync::Arc;
33

44
use super::user::DbUserRepository;
5-
use crate::config::{Configuration, ConfigurationPublic, TorrustIndex};
5+
use crate::config::{Configuration, ConfigurationPublic, Settings};
66
use crate::errors::ServiceError;
77
use crate::models::user::UserId;
88

@@ -25,7 +25,7 @@ impl Service {
2525
/// # Errors
2626
///
2727
/// It returns an error if the user does not have the required permissions.
28-
pub async fn get_all(&self, user_id: &UserId) -> Result<TorrustIndex, ServiceError> {
28+
pub async fn get_all(&self, user_id: &UserId) -> Result<Settings, ServiceError> {
2929
let user = self.user_repository.get_compact(user_id).await?;
3030

3131
// Check if user is administrator
@@ -44,7 +44,7 @@ impl Service {
4444
/// # Errors
4545
///
4646
/// It returns an error if the user does not have the required permissions.
47-
pub async fn get_all_masking_secrets(&self, user_id: &UserId) -> Result<TorrustIndex, ServiceError> {
47+
pub async fn get_all_masking_secrets(&self, user_id: &UserId) -> Result<Settings, ServiceError> {
4848
let user = self.user_repository.get_compact(user_id).await?;
4949

5050
// Check if user is administrator

src/web/api/client/v1/contexts/settings/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
44

55
use crate::config::{
66
Api as DomainApi, Auth as DomainAuth, Database as DomainDatabase, ImageCache as DomainImageCache, Mail as DomainMail,
7-
Network as DomainNetwork, TorrustIndex as DomainSettings, Tracker as DomainTracker,
7+
Network as DomainNetwork, Settings as DomainSettings, Tracker as DomainTracker,
88
TrackerStatisticsImporter as DomainTrackerStatisticsImporter, Website as DomainWebsite,
99
};
1010

src/web/api/server/v1/contexts/settings/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
//! ```
8383
//! **Resource**
8484
//!
85-
//! Refer to the [`TorrustIndex`](crate::config::TorrustIndex)
85+
//! Refer to the [`TorrustIndex`](crate::config::Settings)
8686
//! struct for more information about the response attributes.
8787
//!
8888
//! # Update all settings
@@ -110,7 +110,7 @@
110110
//!
111111
//! **Resource**
112112
//!
113-
//! Refer to the [`TorrustIndex`](crate::config::TorrustIndex)
113+
//! Refer to the [`TorrustIndex`](crate::config::Settings)
114114
//! struct for more information about the response attributes.
115115
//!
116116
//! # Get site name

tests/common/contexts/settings/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pub mod responses;
33
use serde::{Deserialize, Serialize};
44
use torrust_index::config::{
55
Api as DomainApi, Auth as DomainAuth, Database as DomainDatabase, ImageCache as DomainImageCache, Mail as DomainMail,
6-
Network as DomainNetwork, TorrustIndex as DomainSettings, Tracker as DomainTracker,
6+
Network as DomainNetwork, Settings as DomainSettings, Tracker as DomainTracker,
77
TrackerStatisticsImporter as DomainTrackerStatisticsImporter, Website as DomainWebsite,
88
};
99

tests/environments/app_starter.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use torrust_index::{app, config};
99

1010
/// It launches the app and provides a way to stop it.
1111
pub struct AppStarter {
12-
configuration: config::TorrustIndex,
12+
configuration: config::Settings,
1313
/// The application binary state (started or not):
1414
/// - `None`: if the app is not started,
1515
/// - `RunningState`: if the app was started.
@@ -18,7 +18,7 @@ pub struct AppStarter {
1818

1919
impl AppStarter {
2020
#[must_use]
21-
pub fn with_custom_configuration(configuration: config::TorrustIndex) -> Self {
21+
pub fn with_custom_configuration(configuration: config::Settings) -> Self {
2222
Self {
2323
configuration,
2424
running_state: None,
@@ -78,7 +78,7 @@ impl AppStarter {
7878
}
7979

8080
#[must_use]
81-
pub fn server_configuration(&self) -> config::TorrustIndex {
81+
pub fn server_configuration(&self) -> config::Settings {
8282
self.configuration.clone()
8383
}
8484

tests/environments/isolated.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl TestEnv {
4646

4747
/// Provides the whole server configuration.
4848
#[must_use]
49-
pub fn server_configuration(&self) -> config::TorrustIndex {
49+
pub fn server_configuration(&self) -> config::Settings {
5050
self.app_starter.server_configuration()
5151
}
5252

@@ -69,10 +69,10 @@ impl Default for TestEnv {
6969
}
7070

7171
/// Provides a configuration with ephemeral data for testing.
72-
fn ephemeral(temp_dir: &TempDir) -> config::TorrustIndex {
73-
let mut configuration = config::TorrustIndex {
72+
fn ephemeral(temp_dir: &TempDir) -> config::Settings {
73+
let mut configuration = config::Settings {
7474
log_level: Some("off".to_owned()), // Change to `debug` for tests debugging
75-
..config::TorrustIndex::default()
75+
..config::Settings::default()
7676
};
7777

7878
// Ephemeral API port

0 commit comments

Comments
 (0)