pub struct ValidateCommandHandler;Expand description
Application layer handler for validate command
This handler validates environment configuration files by:
- Parsing the JSON structure
- Validating field types and values
- Verifying referenced files exist (SSH keys)
- Checking domain constraints
Implementations§
Source§impl ValidateCommandHandler
impl ValidateCommandHandler
Sourcepub fn validate(
&self,
config_path: &Path,
) -> Result<ValidationResult, ValidateCommandHandlerError>
pub fn validate( &self, config_path: &Path, ) -> Result<ValidationResult, ValidateCommandHandlerError>
Validate an environment configuration file
This method performs comprehensive validation:
- JSON syntax and structure
- Field types and constraints
- SSH key file existence
- Domain business rules
§Arguments
config_path- Path to the configuration file to validate
§Returns
Ok(ValidationResult)- Configuration is valid with detailsErr(ValidateCommandHandlerError)- Validation failed with specific reason
§Errors
Returns an error if:
- File cannot be read
- JSON syntax is invalid
- Required fields are missing
- Field values violate constraints
- Referenced SSH keys don’t exist
- Domain rules are violated
§Examples
use std::path::Path;
use torrust_tracker_deployer_lib::application::command_handlers::validate::ValidateCommandHandler;
let handler = ValidateCommandHandler::new();
let result = handler.validate(Path::new("envs/my-env.json"))?;
println!("Configuration is valid!");
println!("Environment name: {}", result.environment_name);Trait Implementations§
Auto Trait Implementations§
impl Freeze for ValidateCommandHandler
impl RefUnwindSafe for ValidateCommandHandler
impl Send for ValidateCommandHandler
impl Sync for ValidateCommandHandler
impl Unpin for ValidateCommandHandler
impl UnsafeUnpin for ValidateCommandHandler
impl UnwindSafe for ValidateCommandHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request