1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use Debug;
/// An `ICommand` represents business API call.
///
/// The name of an `ICommand` should always be in the present
/// tense, e.g.,
/// - `ChangeEmailAddress`
/// - `AddDependency`
///
/// To simplify serialization, a command should be an enum, and each
/// element should have a payload. By convention, the payload has the
/// same name as the element, and elements that do not require
/// additional information use an empty payload.
///
/// Though the `ICommand` trait only has a single function, the
/// commands must also derive a number of standard traits.
/// - `Clone` - events may be cloned throughout the framework
/// - `Debug` and `PartialEq` - needed for effective testing
///
/// # Examples
/// ```rust
/// use std::fmt::Debug;
///
/// use cqrs_es2::ICommand;
///
/// #[derive(Debug, PartialEq, Clone)]
/// pub enum CustomerCommand {
/// AddCustomerName(AddCustomerName),
/// UpdateEmail(UpdateEmail),
/// }
///
/// #[derive(Debug, PartialEq, Clone)]
/// pub struct AddCustomerName {
/// changed_name: String,
/// }
///
/// #[derive(Debug, PartialEq, Clone)]
/// pub struct UpdateEmail {
/// new_email: String,
/// }
///
/// impl ICommand for CustomerCommand {};
/// ```