-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: [#581] move semantic validation
to the type that has the knowledge.
- Loading branch information
1 parent
790e1ec
commit 8d3c8cb
Showing
5 changed files
with
73 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//! Trait to validate the whole settings of sections of the settings. | ||
use thiserror::Error; | ||
use torrust_index_located_error::LocatedError; | ||
use url::ParseError; | ||
|
||
/// Errors that can occur validating the configuration. | ||
#[derive(Error, Debug)] | ||
pub enum ValidationError { | ||
/// Unable to load the configuration from the configuration file. | ||
#[error("Invalid tracker URL: {source}")] | ||
InvalidTrackerUrl { source: LocatedError<'static, ParseError> }, | ||
|
||
#[error("UDP private trackers are not supported. URL schemes for private tracker URLs must be HTTP ot HTTPS")] | ||
UdpTrackersInPrivateModeNotSupported, | ||
} | ||
|
||
pub trait Validator { | ||
/// # Errors | ||
/// | ||
/// Will return an error if the configuration is invalid. | ||
fn validate(&self) -> Result<(), ValidationError>; | ||
} |