Skip to content

Commit

Permalink
feat: get pending ops from current txn as json (#676)
Browse files Browse the repository at this point in the history
* get pending ops from current txn as json

* fix: add ChangeRef

* change the name of func pending

* chore: changeset

---------

Co-authored-by: Leon Zhao <leeeon233@gmail.com>
Co-authored-by: Zixuan Chen <remch183@outlook.com>
  • Loading branch information
3 people authored Mar 3, 2025
1 parent f898fac commit 4cb7ae3
Show file tree
Hide file tree
Showing 7 changed files with 407 additions and 253 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-gifts-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"loro-crdt": patch
---

feat: get ops from current txn as json #676
22 changes: 22 additions & 0 deletions crates/loro-internal/src/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ pub struct Change<O = Op> {
pub(crate) ops: RleVec<[O; 1]>,
}

pub(crate) struct ChangeRef<'a, O = Op> {
pub(crate) id: &'a ID,
pub(crate) lamport: &'a Lamport,
pub(crate) deps: &'a Frontiers,
pub(crate) timestamp: &'a Timestamp,
pub(crate) commit_msg: &'a Option<Arc<str>>,
pub(crate) ops: &'a RleVec<[O; 1]>,
}

impl<'a, O> ChangeRef<'a, O> {
pub fn from_change(change: &'a Change<O>) -> Self {
Self {
id: &change.id,
lamport: &change.lamport,
deps: &change.deps,
timestamp: &change.timestamp,
commit_msg: &change.commit_msg,
ops: &change.ops,
}
}
}

impl<O> Change<O> {
pub fn new(
ops: RleVec<[O; 1]>,
Expand Down
Loading

0 comments on commit 4cb7ae3

Please sign in to comment.