coven_replication/sync/store/pull/
materialization.rs1use super::*;
2
3pub enum Readiness {
4 Ready,
5 AlreadyMaterialized,
6 Held(HeldStorePosition),
7}
8
9pub(crate) fn held_object_error(error: StoreObjectError) -> HeldStorePositionReason {
10 match error {
11 StoreObjectError::Storage(source) => HeldStorePositionReason::ObjectUnreadableStorage {
12 key: "exact Store object".to_string(),
13 source: source.into(),
14 },
15 StoreObjectError::InvalidObject { key, source, .. } => match *source {
16 StoreProtocolError::InvalidSignature => HeldStorePositionReason::InvalidSignature,
17 StoreProtocolError::RelocatedSlot { .. }
18 | StoreProtocolError::RelocatedPackage { .. }
19 | StoreProtocolError::StoreRootMismatch { .. }
20 | StoreProtocolError::StoreMismatch { .. }
21 | StoreProtocolError::FounderMismatch { .. } => {
22 HeldStorePositionReason::WrongSlotProtocol(source.into())
23 }
24 source => HeldStorePositionReason::ObjectUnreadableProtocol {
25 key,
26 source: source.into(),
27 },
28 },
29 }
30}
31
32pub(super) fn historical_local_store_membership(
33 latest: LocalStoreMembership,
34 candidate: LocalStoreMembership,
35) -> LocalStoreMembership {
36 if matches!(latest, LocalStoreMembership::Removed)
37 || matches!(candidate, LocalStoreMembership::Removed)
38 {
39 LocalStoreMembership::Removed
40 } else if matches!(latest, LocalStoreMembership::Current)
41 && matches!(candidate, LocalStoreMembership::Current)
42 {
43 LocalStoreMembership::Current
44 } else if matches!(latest, LocalStoreMembership::IdentityNotSupplied)
45 || matches!(candidate, LocalStoreMembership::IdentityNotSupplied)
46 {
47 LocalStoreMembership::IdentityNotSupplied
48 } else {
49 LocalStoreMembership::NotYetMember
50 }
51}