mz_adapter_types/
timestamp_selection.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10use serde::{Deserialize, Serialize};
11use std::default::Default;
12
13/// Whether to use the constraint-based timestamp selection.
14#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
15pub enum ConstraintBasedTimestampSelection {
16    Enabled,
17    Disabled,
18    Verify,
19}
20
21impl Default for ConstraintBasedTimestampSelection {
22    fn default() -> Self {
23        Self::Enabled
24    }
25}
26
27impl ConstraintBasedTimestampSelection {
28    pub const fn const_default() -> Self {
29        Self::Enabled
30    }
31
32    pub fn from_str(s: &str) -> Self {
33        match s {
34            "enabled" => Self::Enabled,
35            "disabled" => Self::Disabled,
36            "verify" => Self::Verify,
37            _ => {
38                tracing::error!("invalid value for ConstraintBasedTimestampSelection: {}", s);
39                ConstraintBasedTimestampSelection::default()
40            }
41        }
42    }
43
44    pub const fn as_str(&self) -> &'static str {
45        match self {
46            Self::Enabled => "enabled",
47            Self::Disabled => "disabled",
48            Self::Verify => "verify",
49        }
50    }
51}