Something went wrong. Try again.
A public mirror for the whole atmosphere hubble.microcosm.blue
Something went wrong. Try again.
1.1 kB · 35 lines
Rust
at main
123456789101112131415161718192021222324252627282930313233343536//! The operations a commit claims it applied.
use crate::cid::Cid;use crate::error::OpKind;use crate::key::Key;
/// One record operation from a firehose commit, as inversion needs it.////// Every variant carries the previous value, because sync 1.1 requires/// producers to send it: without it an operation cannot be inverted at all.#[derive(Debug, Clone, PartialEq, Eq)]pub enum Op { /// A record appeared at `key` holding `cid`. Create { key: Key, cid: Cid }, /// The record at `key` changed from `prev` to `cid`. Update { key: Key, cid: Cid, prev: Cid }, /// The record at `key`, which held `prev`, went away. Delete { key: Key, prev: Cid },}
impl Op { pub fn key(&self) -> &Key { match self { Op::Create { key, .. } | Op::Update { key, .. } | Op::Delete { key, .. } => key, } }
pub fn kind(&self) -> OpKind { match self { Op::Create { .. } => OpKind::Create, Op::Update { .. } => OpKind::Update, Op::Delete { .. } => OpKind::Delete, } }}