Skip to content

Commit 4cb7ae3

Browse files
YngNsLeeeon233zxch3n
authored
feat: get pending ops from current txn as json (#676)
* get pending ops from current txn as json * fix: add ChangeRef * change the name of func pending * chore: changeset --------- Co-authored-by: Leon Zhao <[email protected]> Co-authored-by: Zixuan Chen <[email protected]>
1 parent f898fac commit 4cb7ae3

File tree

7 files changed

+407
-253
lines changed

7 files changed

+407
-253
lines changed

.changeset/late-gifts-jog.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"loro-crdt": patch
3+
---
4+
5+
feat: get ops from current txn as json #676

crates/loro-internal/src/change.rs

+22
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ pub struct Change<O = Op> {
3838
pub(crate) ops: RleVec<[O; 1]>,
3939
}
4040

41+
pub(crate) struct ChangeRef<'a, O = Op> {
42+
pub(crate) id: &'a ID,
43+
pub(crate) lamport: &'a Lamport,
44+
pub(crate) deps: &'a Frontiers,
45+
pub(crate) timestamp: &'a Timestamp,
46+
pub(crate) commit_msg: &'a Option<Arc<str>>,
47+
pub(crate) ops: &'a RleVec<[O; 1]>,
48+
}
49+
50+
impl<'a, O> ChangeRef<'a, O> {
51+
pub fn from_change(change: &'a Change<O>) -> Self {
52+
Self {
53+
id: &change.id,
54+
lamport: &change.lamport,
55+
deps: &change.deps,
56+
timestamp: &change.timestamp,
57+
commit_msg: &change.commit_msg,
58+
ops: &change.ops,
59+
}
60+
}
61+
}
62+
4163
impl<O> Change<O> {
4264
pub fn new(
4365
ops: RleVec<[O; 1]>,

0 commit comments

Comments
 (0)