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
#[derive(Debug, Clone, Copy, PartialEq, serde::Serialize)]
/// What to do when an error occurs.
#[serde(rename_all = "kebab-case")]
pub enum ErrorBehavior {
  /// The operation will commit what has succeeded.
  Commit = 0,
  /// The operation will rollback changes.
  Rollback = 1,
  /// Errors will be ignored.
  Ignore = 2,
}

impl Default for ErrorBehavior {
  fn default() -> Self {
    Self::Ignore
  }
}

impl std::fmt::Display for ErrorBehavior {
  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    match self {
      Self::Commit => write!(f, "commit"),
      Self::Rollback => write!(f, "rollback"),
      Self::Ignore => write!(f, "ignore"),
    }
  }
}