Struct loro_internal::oplog::OpLog
source · pub struct OpLog { /* private fields */ }Expand description
OpLog store all the ops i.e. the history. It allows multiple [AppState] to attach to it. So you can derive different versions of the state from the OpLog. It allows us to build a version control system.
The causal graph should always be a DAG and complete. So we can always find the LCA.
If deps are missing, we can’t import the change. It will be put into the pending_changes.
Implementations§
source§impl OpLog
impl OpLog
pub fn new() -> Self
pub fn new_with_arena(arena: SharedArena) -> Self
pub fn latest_timestamp(&self) -> Timestamp
pub fn dag(&self) -> &AppDag
pub fn get_timestamp_of_version(&self, f: &Frontiers) -> Timestamp
pub fn is_empty(&self) -> bool
pub fn changes(&self) -> &FxHashMap<PeerID, Vec<Change>>
sourcepub fn import_local_change(
&mut self,
change: Change,
from_txn: bool
) -> Result<(), LoroError>
pub fn import_local_change( &mut self, change: Change, from_txn: bool ) -> Result<(), LoroError>
Import a change.
Pending changes that haven’t been applied to the dag. A change can be imported only when all its deps are already imported. Key is the ID of the missing dep
Err
- Return Err(LoroError::UsedOpID) when the change’s id is occupied
- Return Err(LoroError::DecodeError) when the change’s deps are missing
pub fn next_lamport(&self) -> Lamport
pub fn next_id(&self, peer: PeerID) -> ID
pub fn get_peer_changes(&self, peer: PeerID) -> Option<&Vec<Change>>
sourcepub fn cmp_frontiers(&self, other: &Frontiers) -> Ordering
pub fn cmp_frontiers(&self, other: &Frontiers) -> Ordering
- Ordering::Less means self is less than target or parallel
- Ordering::Equal means versions equal
- Ordering::Greater means self’s version is greater than target
pub fn get_change_at(&self, id: ID) -> Option<&Change>
pub fn get_remote_change_at(&self, id: ID) -> Option<Change<RemoteOp<'_>>>
pub fn export_from(&self, vv: &VersionVector) -> Vec<u8> ⓘ
pub fn decode(&mut self, data: &[u8]) -> Result<(), LoroError>
pub fn diagnose_size(&self) -> SizeInfo
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for OpLog
impl Send for OpLog
impl Sync for OpLog
impl Unpin for OpLog
impl UnwindSafe for OpLog
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more