Skip to main content

data_model/
compat.rs

1use crate::schema::SchemaVersion;
2
3#[derive(Clone, Copy, Debug, Eq, PartialEq)]
4pub enum CompatibilityPolicy {
5    Exact,
6    BackwardCompatible,
7    ForwardCompatible,
8}
9
10impl CompatibilityPolicy {
11    pub fn check(self, writer: SchemaVersion, reader: SchemaVersion) -> bool {
12        match self {
13            Self::Exact => writer == reader,
14            Self::BackwardCompatible => writer.0 >= reader.0,
15            Self::ForwardCompatible => writer.0 <= reader.0,
16        }
17    }
18}