Directive

Trait Directive 

Source
pub trait Directive {
    // Required method
    fn validate(&self) -> HexResult<()>;
}
Expand description

Trait for directives that represent write operations.

Directives express the intent to modify system state. They should be immutable and contain all data needed to execute the operation.

§Example

use hexser::application::Directive;
use hexser::HexResult;

struct CreateUserDirective {
    email: String,
    password: String,
}

impl Directive for CreateUserDirective {
    fn validate(&self) -> HexResult<()> {
        if self.email.contains('@') {
            Ok(())
        } else {
            Err(hexser::Hexserror::validation("Invalid email"))
        }
    }
}

Required Methods§

Source

fn validate(&self) -> HexResult<()>

Validate the directive before execution.

Returns Ok(()) if the directive is valid, or an error describing validation failures.

Implementors§