sdf-metadata 0.14.0

metadata definition for core sdf
Documentation
use crate::wit::io::ConsumerConfig;

impl ConsumerConfig {
    pub fn merge(&mut self, other: &ConsumerConfig) {
        if self.default_starting_offset.is_none() {
            self.default_starting_offset = other.default_starting_offset;
        }
        if self.max_bytes.is_none() {
            self.max_bytes = other.max_bytes;
        }

        if self.isolation.is_none() {
            self.isolation = other.isolation;
        }
    }
}

#[allow(clippy::derivable_impls)]
impl Default for ConsumerConfig {
    fn default() -> Self {
        Self {
            default_starting_offset: None,
            max_bytes: None,
            isolation: None,
        }
    }
}

#[cfg(test)]
mod test {
    use crate::wit::io::Offset;

    #[test]
    fn test_consumer_config_merge() {
        let mut config1 = super::ConsumerConfig {
            default_starting_offset: Some(Offset::Beginning(0)),
            ..Default::default()
        };

        let config2 = super::ConsumerConfig {
            default_starting_offset: Some(Offset::End(0)),
            max_bytes: Some(1024),
            isolation: Some(crate::wit::io::Isolation::ReadCommitted),
        };

        config1.merge(&config2);

        assert_eq!(config1.default_starting_offset, Some(Offset::Beginning(0)));
        assert_eq!(config1.max_bytes, Some(1024));
        assert_eq!(
            config1.isolation,
            Some(crate::wit::io::Isolation::ReadCommitted)
        );
    }
}