use crate::schema::SchemaVersion;

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum CompatibilityPolicy {
    Exact,
    BackwardCompatible,
    ForwardCompatible,
}

impl CompatibilityPolicy {
    pub fn check(self, writer: SchemaVersion, reader: SchemaVersion) -> bool {
        match self {
            Self::Exact => writer == reader,
            Self::BackwardCompatible => writer.0 >= reader.0,
            Self::ForwardCompatible => writer.0 <= reader.0,
        }
    }
}
