pub fn check_meta_version_maybe_delete_data<B: Blob>(b: &mut B) -> Result<(), Error> {
    let meta = match block_on(b.get("META"))? {
        None => return Ok(()),
        Some(bytes) => bytes,
    };

    let current_version = ProtoMeta::ENCODING_VERSION;
    let persisted_version = ProtoMeta::encoded_version(&meta)?;

    if current_version == persisted_version {
        // Nothing to do here, everything is working as expected.
        Ok(())
    } else if current_version > persisted_version {
        // Delete all the keys, as we are upgrading to a new version.
        log::info!(
            "Persistence beta detected version mismatch. Deleting all previously persisted data as part of upgrade from version {} to {}.",
            persisted_version,
            current_version
        );
        let keys = block_on(b.list_keys())?;
        for key in keys {
            block_on(b.delete(&key))?;
        }

        Ok(())
    } else {
        // We are reading a version further in advance than current,
        // likely because a user has downgraded to an older version of
        // Materialize.
        Err(Error::from(format!(
            "invalid persistence version found {} can only read {}. hint: try upgrading Materialize or deleting the previously persisted data.",
            persisted_version, current_version
        )))
    }
}
/// Sanity check whether we can decode the Blob's persisted meta object, and delete
/// all data if the encoded version is less than what the current implementation supports.
///
/// TODO: this is a hack and we will need to get rid of this once we have a
/// proper backwards compatibility policy.
Sanity check whether we can decode the Blob's persisted meta object, and delete
all data if the encoded version is less than what the current implementation supports.

this is a hack and we will need to get rid of this once we have a
proper backwards compatibility policy.
Sanity check whether we can decode the Blob ' s persisted meta object and delete all data if the encoded version is less than what the current implementation supports . this is a hack and we will need to get rid of this once we have a proper backwards compatibility policy .
pub fn check_meta_version_maybe_delete_data<B: Blob>(b: &mut B) -> Result<(), Error> {
    let meta = match block_on(b.get("META"))? {
        None => return Ok(()),
        Some(bytes) => bytes,
    };
    let current_version = ProtoMeta::ENCODING_VERSION;
    let persisted_version = ProtoMeta::encoded_version(&meta)?;
    if current_version == persisted_version {
        // Nothing to do here, everything is working as expected.
        Ok(())
    } else if current_version > persisted_version {
        // Delete all the keys, as we are upgrading to a new version.
        log::info!(
            "Persistence beta detected version mismatch. Deleting all previously persisted data as part of upgrade from version {} to {}.",
            persisted_version,
            current_version
        );
        let keys = block_on(b.list_keys())?;
        for key in keys {
            block_on(b.delete(&key))?;
        }
        Ok(())
    } else {
        // We are reading a version further in advance than current,
        // likely because a user has downgraded to an older version of
        // Materialize.
        Err(Error::from(format!(
            "invalid persistence version found {} can only read {}. hint: try upgrading Materialize or deleting the previously persisted data.",
            persisted_version, current_version
        )))
    }
}
pub fn check_meta_version_maybe_delete_data < B : Blob > ( b : & mut B ) -> Result < ( ) , Error > { let meta = match block_on ( b . get ( " " ) ) ? { None => return Ok ( ( ) ) , Some ( bytes ) => bytes , } ; let current_version = ProtoMeta :: ENCODING_VERSION ; let persisted_version = ProtoMeta :: encoded_version ( & meta ) ? ; if current_version == persisted_version { // Nothing to do here, everything is working as expected. Ok ( ( ) ) } else if current_version > persisted_version { // Delete all the keys, as we are upgrading to a new version. log :: info ! ( " " persisted_version current_version ) ; let keys = block_on ( b . list_keys ( ) ) ? ; for key in keys { block_on ( b . delete ( & key ) ) ? ; } Ok ( ( ) ) } else { // We are reading a version further in advance than current, // likely because a user has downgraded to an older version of // Materialize. Err ( Error :: from ( format ! ( " " persisted_version current_version ) ) ) } }
Sanity check whether we can decode the Blob's persisted meta object, and delete
all data if the encoded version is less than what the current implementation supports.
Sanity check whether we can decode the Blob ' s persisted meta object and delete all data if the encoded version is less than what the current implementation supports .
b
&mut B
b
&mut B