y-rb 0.2.0-x86_64-linux → 0.3.0-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/yrb/Cargo.toml +1 -1
- data/ext/yrb/src/awareness.rs +26 -41
- data/ext/yrb/src/lib.rs +87 -152
- data/ext/yrb/src/utils.rs +1 -3
- data/ext/yrb/src/yany.rs +1 -1
- data/ext/yrb/src/yarray.rs +24 -54
- data/ext/yrb/src/yawareness.rs +10 -18
- data/ext/yrb/src/ydoc.rs +2 -6
- data/ext/yrb/src/ymap.rs +18 -35
- data/ext/yrb/src/ytext.rs +29 -56
- data/ext/yrb/src/ytransaction.rs +2 -8
- data/ext/yrb/src/yvalue.rs +5 -11
- data/ext/yrb/src/yxml_element.rs +44 -65
- data/ext/yrb/src/yxml_text.rs +26 -47
- data/lib/2.7/yrb.so +0 -0
- data/lib/3.0/yrb.so +0 -0
- data/lib/3.1/yrb.so +0 -0
- data/lib/y/array.rb +2 -0
- data/lib/y/awareness.rb +7 -2
- data/lib/y/doc.rb +1 -1
- data/lib/y/map.rb +2 -0
- data/lib/y/text.rb +1 -1
- data/lib/y/version.rb +1 -1
- data/lib/y/xml.rb +5 -2
- data/lib/y-rb.rb +2 -0
- metadata +5 -5
data/ext/yrb/src/yarray.rs
CHANGED
@@ -26,25 +26,18 @@ impl YArray {
|
|
26
26
|
let v = self.0.borrow().get(index).unwrap();
|
27
27
|
YValue::from(v).into()
|
28
28
|
}
|
29
|
-
pub(crate) fn yarray_insert(
|
30
|
-
&self,
|
31
|
-
transaction: &YTransaction,
|
32
|
-
index: u32,
|
33
|
-
value: Value
|
34
|
-
) {
|
29
|
+
pub(crate) fn yarray_insert(&self, transaction: &YTransaction, index: u32, value: Value) {
|
35
30
|
let yvalue = YValue::from(value);
|
36
31
|
let avalue = Any::from(yvalue);
|
37
|
-
self.0
|
38
|
-
|
39
|
-
index,
|
40
|
-
avalue
|
41
|
-
);
|
32
|
+
self.0
|
33
|
+
.borrow_mut()
|
34
|
+
.insert(&mut *transaction.0.borrow_mut(), index, avalue);
|
42
35
|
}
|
43
36
|
pub(crate) fn yarray_insert_range(
|
44
37
|
&self,
|
45
38
|
transaction: &YTransaction,
|
46
39
|
index: u32,
|
47
|
-
values: RArray
|
40
|
+
values: RArray,
|
48
41
|
) {
|
49
42
|
let arr: Vec<Any> = values
|
50
43
|
.each()
|
@@ -52,11 +45,9 @@ impl YArray {
|
|
52
45
|
.map(|value| YValue::from(value.unwrap()).into())
|
53
46
|
.collect();
|
54
47
|
|
55
|
-
self.0
|
56
|
-
|
57
|
-
index,
|
58
|
-
arr
|
59
|
-
);
|
48
|
+
self.0
|
49
|
+
.borrow_mut()
|
50
|
+
.insert_range(&mut *transaction.0.borrow_mut(), index, arr);
|
60
51
|
}
|
61
52
|
pub(crate) fn yarray_length(&self) -> u32 {
|
62
53
|
return self.0.borrow().len();
|
@@ -82,30 +73,28 @@ impl YArray {
|
|
82
73
|
Change::Added(v) => {
|
83
74
|
let values = v
|
84
75
|
.iter()
|
85
|
-
.map(|v|
|
86
|
-
<YValue as Into<Value>>::into(
|
87
|
-
YValue::from(v.clone())
|
88
|
-
)
|
89
|
-
})
|
76
|
+
.map(|v| <YValue as Into<Value>>::into(YValue::from(v.clone())))
|
90
77
|
.collect::<RArray>();
|
91
78
|
payload.aset(change_added, values)
|
92
79
|
}
|
93
|
-
Change::Retain(position) =>
|
94
|
-
.aset(change_retain, Value::from(*position))
|
95
|
-
|
96
|
-
|
80
|
+
Change::Retain(position) => {
|
81
|
+
payload.aset(change_retain, Value::from(*position))
|
82
|
+
}
|
83
|
+
Change::Removed(position) => {
|
84
|
+
payload.aset(change_removed, Value::from(*position))
|
85
|
+
}
|
97
86
|
};
|
98
87
|
|
99
88
|
match result {
|
100
89
|
Ok(()) => Ok(payload),
|
101
|
-
Err(e) => Err(e)
|
90
|
+
Err(e) => Err(e),
|
102
91
|
}
|
103
92
|
})
|
104
93
|
.partition(Result::is_ok);
|
105
94
|
|
106
95
|
if errors.is_empty() {
|
107
96
|
let args = (RArray::from_vec(
|
108
|
-
changes.into_iter().map(Result::unwrap).collect()
|
97
|
+
changes.into_iter().map(Result::unwrap).collect(),
|
109
98
|
),);
|
110
99
|
let _ = block.call::<(RArray,), Qnil>(args);
|
111
100
|
// todo: make sure we respect the result and bubble up the
|
@@ -119,48 +108,29 @@ impl YArray {
|
|
119
108
|
|
120
109
|
Ok(subscription_id)
|
121
110
|
}
|
122
|
-
pub(crate) fn yarray_push_back(
|
123
|
-
&self,
|
124
|
-
transaction: &YTransaction,
|
125
|
-
value: Value
|
126
|
-
) {
|
111
|
+
pub(crate) fn yarray_push_back(&self, transaction: &YTransaction, value: Value) {
|
127
112
|
let yvalue = YValue::from(value);
|
128
113
|
let avalue = Any::from(yvalue);
|
129
114
|
self.0
|
130
115
|
.borrow_mut()
|
131
116
|
.push_back(&mut *transaction.0.borrow_mut(), avalue)
|
132
117
|
}
|
133
|
-
pub(crate) fn yarray_push_front(
|
134
|
-
&self,
|
135
|
-
transaction: &YTransaction,
|
136
|
-
value: Value
|
137
|
-
) {
|
118
|
+
pub(crate) fn yarray_push_front(&self, transaction: &YTransaction, value: Value) {
|
138
119
|
let yvalue = YValue::from(value);
|
139
120
|
let avalue = Any::from(yvalue);
|
140
121
|
self.0
|
141
122
|
.borrow_mut()
|
142
123
|
.push_front(&mut *transaction.0.borrow_mut(), avalue)
|
143
124
|
}
|
144
|
-
pub(crate) fn yarray_remove(
|
145
|
-
&self,
|
146
|
-
transaction: &YTransaction,
|
147
|
-
index: u32
|
148
|
-
) {
|
125
|
+
pub(crate) fn yarray_remove(&self, transaction: &YTransaction, index: u32) {
|
149
126
|
self.0
|
150
127
|
.borrow_mut()
|
151
128
|
.remove(&mut transaction.0.borrow_mut(), index)
|
152
129
|
}
|
153
|
-
pub(crate) fn yarray_remove_range(
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
len: u32
|
158
|
-
) {
|
159
|
-
self.0.borrow_mut().remove_range(
|
160
|
-
&mut transaction.0.borrow_mut(),
|
161
|
-
index,
|
162
|
-
len
|
163
|
-
)
|
130
|
+
pub(crate) fn yarray_remove_range(&self, transaction: &YTransaction, index: u32, len: u32) {
|
131
|
+
self.0
|
132
|
+
.borrow_mut()
|
133
|
+
.remove_range(&mut transaction.0.borrow_mut(), index, len)
|
164
134
|
}
|
165
135
|
pub(crate) fn yarray_to_a(&self) -> RArray {
|
166
136
|
let arr = self
|
data/ext/yrb/src/yawareness.rs
CHANGED
@@ -23,14 +23,12 @@ impl YAwareness {
|
|
23
23
|
Self(RefCell::new(awareness))
|
24
24
|
}
|
25
25
|
|
26
|
-
pub(crate) fn yawareness_apply_update(
|
27
|
-
&self,
|
28
|
-
update: &YAwarenessUpdate
|
29
|
-
) -> Result<(), Error> {
|
26
|
+
pub(crate) fn yawareness_apply_update(&self, update: &YAwarenessUpdate) -> Result<(), Error> {
|
30
27
|
update.decode().and_then(|value| {
|
31
|
-
self.0
|
32
|
-
|
33
|
-
|
28
|
+
self.0
|
29
|
+
.borrow_mut()
|
30
|
+
.apply_update(value)
|
31
|
+
.map_err(|_error| Error::runtime_error("cannot decode awareness update"))
|
34
32
|
})
|
35
33
|
}
|
36
34
|
|
@@ -50,10 +48,7 @@ impl YAwareness {
|
|
50
48
|
self.0.borrow().local_state().map(|value| value.to_string())
|
51
49
|
}
|
52
50
|
|
53
|
-
pub(crate) fn yawareness_on_update(
|
54
|
-
&self,
|
55
|
-
block: Proc
|
56
|
-
) -> Result<u32, Error> {
|
51
|
+
pub(crate) fn yawareness_on_update(&self, block: Proc) -> Result<u32, Error> {
|
57
52
|
let subscription_id = self
|
58
53
|
.0
|
59
54
|
.borrow_mut()
|
@@ -91,15 +86,13 @@ impl YAwareness {
|
|
91
86
|
|
92
87
|
pub(crate) fn yawareness_update_with_clients(
|
93
88
|
&self,
|
94
|
-
clients: Vec<ClientID
|
89
|
+
clients: Vec<ClientID>,
|
95
90
|
) -> Result<YAwarenessUpdate, Error> {
|
96
91
|
self.0
|
97
92
|
.borrow_mut()
|
98
93
|
.update_with_clients(clients)
|
99
94
|
.map(YAwarenessUpdate::from)
|
100
|
-
.map_err(|_error|
|
101
|
-
Error::runtime_error("cannot update awareness with clients")
|
102
|
-
})
|
95
|
+
.map_err(|_error| Error::runtime_error("cannot update awareness with clients"))
|
103
96
|
}
|
104
97
|
}
|
105
98
|
|
@@ -117,9 +110,8 @@ unsafe impl Send for YAwarenessUpdate {}
|
|
117
110
|
|
118
111
|
impl YAwarenessUpdate {
|
119
112
|
pub(crate) fn decode(&self) -> Result<AwarenessUpdate, Error> {
|
120
|
-
AwarenessUpdate::decode_v1(self.0.borrow())
|
121
|
-
Error::runtime_error("cannot decode awareness update")
|
122
|
-
})
|
113
|
+
AwarenessUpdate::decode_v1(self.0.borrow())
|
114
|
+
.map_err(|_error| Error::runtime_error("cannot decode awareness update"))
|
123
115
|
}
|
124
116
|
pub(crate) fn yawareness_update_encode(&self) -> Vec<u8> {
|
125
117
|
self.0.to_vec()
|
data/ext/yrb/src/ydoc.rs
CHANGED
@@ -13,8 +13,7 @@ impl YDoc {
|
|
13
13
|
|
14
14
|
if client_id.len() == 1 {
|
15
15
|
let value = client_id.first().unwrap();
|
16
|
-
options.client_id =
|
17
|
-
Integer::from_value(*value).unwrap().to_u64().unwrap();
|
16
|
+
options.client_id = Integer::from_value(*value).unwrap().to_u64().unwrap();
|
18
17
|
}
|
19
18
|
|
20
19
|
options.offset_kind = OffsetKind::Utf32;
|
@@ -28,10 +27,7 @@ impl YDoc {
|
|
28
27
|
|
29
28
|
YTransaction(RefCell::new(transaction))
|
30
29
|
}
|
31
|
-
pub(crate) fn ydoc_encode_diff_v1(
|
32
|
-
&self,
|
33
|
-
state_vector: Vec<u8>
|
34
|
-
) -> Result<Vec<u8>, Error> {
|
30
|
+
pub(crate) fn ydoc_encode_diff_v1(&self, state_vector: Vec<u8>) -> Result<Vec<u8>, Error> {
|
35
31
|
StateVector::decode_v1(&*state_vector)
|
36
32
|
.map(|sv| self.0.borrow().encode_state_as_update_v1(&sv))
|
37
33
|
.map_err(|_e| Error::runtime_error("cannot encode diff"))
|
data/ext/yrb/src/ymap.rs
CHANGED
@@ -21,7 +21,7 @@ impl YMap {
|
|
21
21
|
pub(crate) fn ymap_contains(&self, key: Value) -> bool {
|
22
22
|
match indifferent_hash_key(key) {
|
23
23
|
None => false,
|
24
|
-
Some(k) => self.0.borrow().contains(&*k)
|
24
|
+
Some(k) => self.0.borrow().contains(&*k),
|
25
25
|
}
|
26
26
|
}
|
27
27
|
pub(crate) fn ymap_each(&self, proc: Proc) {
|
@@ -42,19 +42,17 @@ impl YMap {
|
|
42
42
|
&self,
|
43
43
|
transaction: &YTransaction,
|
44
44
|
key: Value,
|
45
|
-
value: Value
|
45
|
+
value: Value,
|
46
46
|
) -> Result<(), Error> {
|
47
47
|
match indifferent_hash_key(key) {
|
48
48
|
None => Err(Error::runtime_error(
|
49
|
-
"invalid key type, make sure it is either a Symbol or a String"
|
49
|
+
"invalid key type, make sure it is either a Symbol or a String",
|
50
50
|
)),
|
51
51
|
Some(k) => {
|
52
52
|
let v = Any::from(YValue::from(value));
|
53
|
-
self.0
|
54
|
-
|
55
|
-
k,
|
56
|
-
v
|
57
|
-
);
|
53
|
+
self.0
|
54
|
+
.borrow_mut()
|
55
|
+
.insert(&mut *transaction.0.borrow_mut(), k, v);
|
58
56
|
|
59
57
|
Ok(())
|
60
58
|
}
|
@@ -75,20 +73,15 @@ impl YMap {
|
|
75
73
|
match change {
|
76
74
|
EntryChange::Inserted(v) => {
|
77
75
|
let h = RHash::new();
|
78
|
-
h.aset(
|
79
|
-
|
80
|
-
*YValue::from(v.clone()).0.borrow()
|
81
|
-
)
|
82
|
-
.expect("cannot add change::inserted");
|
76
|
+
h.aset(Symbol::new(key), *YValue::from(v.clone()).0.borrow())
|
77
|
+
.expect("cannot add change::inserted");
|
83
78
|
|
84
79
|
let payload = RHash::new();
|
85
80
|
payload
|
86
81
|
.aset(change_inserted, h)
|
87
82
|
.expect("cannot add change::inserted");
|
88
83
|
|
89
|
-
changes
|
90
|
-
.push(payload)
|
91
|
-
.expect("cannot push changes::payload");
|
84
|
+
changes.push(payload).expect("cannot push changes::payload");
|
92
85
|
}
|
93
86
|
EntryChange::Updated(old, new) => {
|
94
87
|
let values = RArray::with_capacity(2);
|
@@ -108,26 +101,19 @@ impl YMap {
|
|
108
101
|
.aset(change_updated, h)
|
109
102
|
.expect("cannot push change::updated");
|
110
103
|
|
111
|
-
changes
|
112
|
-
.push(payload)
|
113
|
-
.expect("cannot push changes::payload");
|
104
|
+
changes.push(payload).expect("cannot push changes::payload");
|
114
105
|
}
|
115
106
|
EntryChange::Removed(v) => {
|
116
107
|
let h = RHash::new();
|
117
|
-
h.aset(
|
118
|
-
|
119
|
-
*YValue::from(v.clone()).0.borrow()
|
120
|
-
)
|
121
|
-
.expect("cannot push change::removed");
|
108
|
+
h.aset(Symbol::new(key), *YValue::from(v.clone()).0.borrow())
|
109
|
+
.expect("cannot push change::removed");
|
122
110
|
|
123
111
|
let payload = RHash::new();
|
124
112
|
payload
|
125
113
|
.aset(change_removed, h)
|
126
114
|
.expect("cannot push change::removed");
|
127
115
|
|
128
|
-
changes
|
129
|
-
.push(payload)
|
130
|
-
.expect("cannot push changes::payload");
|
116
|
+
changes.push(payload).expect("cannot push changes::payload");
|
131
117
|
}
|
132
118
|
}
|
133
119
|
}
|
@@ -138,11 +124,7 @@ impl YMap {
|
|
138
124
|
})
|
139
125
|
.into()
|
140
126
|
}
|
141
|
-
pub(crate) fn ymap_remove(
|
142
|
-
&self,
|
143
|
-
transaction: &YTransaction,
|
144
|
-
key: Value
|
145
|
-
) -> Option<Value> {
|
127
|
+
pub(crate) fn ymap_remove(&self, transaction: &YTransaction, key: Value) -> Option<Value> {
|
146
128
|
indifferent_hash_key(key)
|
147
129
|
.map(|k| {
|
148
130
|
self.0
|
@@ -157,9 +139,10 @@ impl YMap {
|
|
157
139
|
}
|
158
140
|
pub(crate) fn ymap_to_h(&self) -> RHash {
|
159
141
|
RHash::from_iter(
|
160
|
-
self.0
|
161
|
-
|
162
|
-
|
142
|
+
self.0
|
143
|
+
.borrow()
|
144
|
+
.iter()
|
145
|
+
.map(move |(k, v)| (k.to_string(), *YValue::from(v).0.borrow())),
|
163
146
|
)
|
164
147
|
}
|
165
148
|
pub(crate) fn ymap_unobserve(&self, subscription_id: u32) {
|
data/ext/yrb/src/ytext.rs
CHANGED
@@ -21,15 +21,12 @@ impl YText {
|
|
21
21
|
transaction: &YTransaction,
|
22
22
|
index: u32,
|
23
23
|
length: u32,
|
24
|
-
attrs: RHash
|
24
|
+
attrs: RHash,
|
25
25
|
) -> Result<(), Error> {
|
26
26
|
let a = YAttrs::from(attrs);
|
27
|
-
self.0
|
28
|
-
|
29
|
-
index,
|
30
|
-
length,
|
31
|
-
a.0
|
32
|
-
);
|
27
|
+
self.0
|
28
|
+
.borrow_mut()
|
29
|
+
.format(&mut *transaction.0.borrow_mut(), index, length, a.0);
|
33
30
|
|
34
31
|
Ok(())
|
35
32
|
}
|
@@ -37,13 +34,11 @@ impl YText {
|
|
37
34
|
&self,
|
38
35
|
transaction: &YTransaction,
|
39
36
|
index: u32,
|
40
|
-
chunk: String
|
37
|
+
chunk: String,
|
41
38
|
) -> Result<(), Error> {
|
42
|
-
self.0
|
43
|
-
|
44
|
-
index,
|
45
|
-
&*chunk
|
46
|
-
);
|
39
|
+
self.0
|
40
|
+
.borrow_mut()
|
41
|
+
.insert(&mut *transaction.0.borrow_mut(), index, &*chunk);
|
47
42
|
|
48
43
|
Ok(())
|
49
44
|
}
|
@@ -51,16 +46,14 @@ impl YText {
|
|
51
46
|
&self,
|
52
47
|
transaction: &YTransaction,
|
53
48
|
index: u32,
|
54
|
-
content: Value
|
49
|
+
content: Value,
|
55
50
|
) -> Result<(), Error> {
|
56
51
|
let yvalue = YValue::from(content);
|
57
52
|
let avalue = Any::from(yvalue);
|
58
53
|
|
59
|
-
self.0
|
60
|
-
|
61
|
-
index,
|
62
|
-
avalue
|
63
|
-
);
|
54
|
+
self.0
|
55
|
+
.borrow_mut()
|
56
|
+
.insert_embed(&mut *transaction.0.borrow_mut(), index, avalue);
|
64
57
|
|
65
58
|
Ok(())
|
66
59
|
}
|
@@ -69,7 +62,7 @@ impl YText {
|
|
69
62
|
transaction: &YTransaction,
|
70
63
|
index: u32,
|
71
64
|
embed: Value,
|
72
|
-
attrs: RHash
|
65
|
+
attrs: RHash,
|
73
66
|
) -> Result<(), Error> {
|
74
67
|
let yvalue = YValue::from(embed);
|
75
68
|
let avalue = Any::from(yvalue);
|
@@ -80,7 +73,7 @@ impl YText {
|
|
80
73
|
&mut *transaction.0.borrow_mut(),
|
81
74
|
index,
|
82
75
|
avalue,
|
83
|
-
a.0
|
76
|
+
a.0,
|
84
77
|
);
|
85
78
|
|
86
79
|
Ok(())
|
@@ -90,7 +83,7 @@ impl YText {
|
|
90
83
|
transaction: &YTransaction,
|
91
84
|
index: u32,
|
92
85
|
chunk: String,
|
93
|
-
attrs: RHash
|
86
|
+
attrs: RHash,
|
94
87
|
) -> Result<(), Error> {
|
95
88
|
let a = YAttrs::from(attrs);
|
96
89
|
|
@@ -98,7 +91,7 @@ impl YText {
|
|
98
91
|
&mut *transaction.0.borrow_mut(),
|
99
92
|
index,
|
100
93
|
&*chunk,
|
101
|
-
a.0
|
94
|
+
a.0,
|
102
95
|
);
|
103
96
|
|
104
97
|
Ok(())
|
@@ -133,22 +126,14 @@ impl YText {
|
|
133
126
|
.into_iter()
|
134
127
|
.map(|(key, val)| {
|
135
128
|
let yvalue = YValue::from(val);
|
136
|
-
(
|
137
|
-
key.to_string(),
|
138
|
-
yvalue.0.into_inner()
|
139
|
-
)
|
129
|
+
(key.to_string(), yvalue.0.into_inner())
|
140
130
|
})
|
141
131
|
.collect::<RHash>()
|
142
132
|
.into(),
|
143
|
-
None => None
|
144
|
-
})
|
145
|
-
.map(|attrs_hash| {
|
146
|
-
attrs_hash
|
147
|
-
.map(|v| payload.aset(attributes, v))
|
148
|
-
})
|
149
|
-
.map(|_| {
|
150
|
-
block.call::<(RHash,), Qnil>((payload,))
|
133
|
+
None => None,
|
151
134
|
})
|
135
|
+
.map(|attrs_hash| attrs_hash.map(|v| payload.aset(attributes, v)))
|
136
|
+
.map(|_| block.call::<(RHash,), Qnil>((payload,)))
|
152
137
|
}
|
153
138
|
Delta::Retain(index, attrs) => {
|
154
139
|
let payload = RHash::new();
|
@@ -163,22 +148,14 @@ impl YText {
|
|
163
148
|
.into_iter()
|
164
149
|
.map(|(key, val)| {
|
165
150
|
let yvalue = YValue::from(val);
|
166
|
-
(
|
167
|
-
key.to_string(),
|
168
|
-
yvalue.0.into_inner()
|
169
|
-
)
|
151
|
+
(key.to_string(), yvalue.0.into_inner())
|
170
152
|
})
|
171
153
|
.collect::<RHash>()
|
172
154
|
.into(),
|
173
|
-
None => None
|
174
|
-
})
|
175
|
-
.map(|attrs_hash| {
|
176
|
-
attrs_hash
|
177
|
-
.map(|v| payload.aset(attributes, v))
|
178
|
-
})
|
179
|
-
.map(|_| {
|
180
|
-
block.call::<(RHash,), Qnil>((payload,))
|
155
|
+
None => None,
|
181
156
|
})
|
157
|
+
.map(|attrs_hash| attrs_hash.map(|v| payload.aset(attributes, v)))
|
158
|
+
.map(|_| block.call::<(RHash,), Qnil>((payload,)))
|
182
159
|
}
|
183
160
|
Delta::Deleted(index) => {
|
184
161
|
let payload = RHash::new();
|
@@ -187,9 +164,7 @@ impl YText {
|
|
187
164
|
|
188
165
|
payload
|
189
166
|
.aset(delta_delete, yvalue.0.into_inner())
|
190
|
-
.map(|()|
|
191
|
-
block.call::<(RHash,), Qnil>((payload,))
|
192
|
-
})
|
167
|
+
.map(|()| block.call::<(RHash,), Qnil>((payload,)))
|
193
168
|
}
|
194
169
|
})
|
195
170
|
.partition(Result::is_ok);
|
@@ -212,13 +187,11 @@ impl YText {
|
|
212
187
|
&self,
|
213
188
|
transaction: &YTransaction,
|
214
189
|
start: u32,
|
215
|
-
length: u32
|
190
|
+
length: u32,
|
216
191
|
) -> Result<(), Error> {
|
217
|
-
self.0
|
218
|
-
|
219
|
-
start,
|
220
|
-
length
|
221
|
-
);
|
192
|
+
self.0
|
193
|
+
.borrow_mut()
|
194
|
+
.remove_range(&mut *transaction.0.borrow_mut(), start, length);
|
222
195
|
|
223
196
|
Ok(())
|
224
197
|
}
|
data/ext/yrb/src/ytransaction.rs
CHANGED
@@ -16,10 +16,7 @@ pub(crate) struct YTransaction(pub(crate) RefCell<Transaction>);
|
|
16
16
|
unsafe impl Send for YTransaction {}
|
17
17
|
|
18
18
|
impl YTransaction {
|
19
|
-
pub(crate) fn ytransaction_apply_update(
|
20
|
-
&self,
|
21
|
-
update: Vec<u8>
|
22
|
-
) -> Result<(), Error> {
|
19
|
+
pub(crate) fn ytransaction_apply_update(&self, update: Vec<u8>) -> Result<(), Error> {
|
23
20
|
return Update::decode_v1(update.as_slice())
|
24
21
|
.map(|u| self.0.borrow_mut().apply_update(u))
|
25
22
|
.map_err(|_e| Error::runtime_error("cannot apply update"));
|
@@ -42,10 +39,7 @@ impl YTransaction {
|
|
42
39
|
|
43
40
|
YText(RefCell::new(t))
|
44
41
|
}
|
45
|
-
pub(crate) fn ytransaction_get_xml_element(
|
46
|
-
&self,
|
47
|
-
name: String
|
48
|
-
) -> YXmlElement {
|
42
|
+
pub(crate) fn ytransaction_get_xml_element(&self, name: String) -> YXmlElement {
|
49
43
|
let el = self.0.borrow_mut().get_xml_element(&*name);
|
50
44
|
|
51
45
|
YXmlElement(RefCell::new(el))
|
data/ext/yrb/src/yvalue.rs
CHANGED
@@ -2,15 +2,11 @@ use crate::{YText, YXmlElement, YXmlText};
|
|
2
2
|
use lib0::any::Any;
|
3
3
|
use magnus::r_hash::ForEach::Continue;
|
4
4
|
use magnus::value::Qnil;
|
5
|
-
use magnus::{
|
6
|
-
class, Float, Integer, RArray, RHash, RString, Symbol, Value, QNIL
|
7
|
-
};
|
5
|
+
use magnus::{class, Float, Integer, RArray, RHash, RString, Symbol, Value, QNIL};
|
8
6
|
use std::cell::RefCell;
|
9
7
|
use std::collections::HashMap;
|
10
8
|
use yrs::types::Value as YrsValue;
|
11
|
-
use yrs::{
|
12
|
-
Text as YrsText, XmlElement as YrsXmlElement, XmlText as YrsXmlText
|
13
|
-
};
|
9
|
+
use yrs::{Text as YrsText, XmlElement as YrsXmlElement, XmlText as YrsXmlText};
|
14
10
|
|
15
11
|
pub(crate) struct YValue(pub(crate) RefCell<Value>);
|
16
12
|
|
@@ -77,7 +73,7 @@ impl From<YrsText> for YValue {
|
|
77
73
|
impl From<YrsXmlElement> for YValue {
|
78
74
|
fn from(value: YrsXmlElement) -> Self {
|
79
75
|
YValue(RefCell::from(Value::from(YXmlElement(RefCell::from(
|
80
|
-
value
|
76
|
+
value,
|
81
77
|
)))))
|
82
78
|
}
|
83
79
|
}
|
@@ -150,10 +146,7 @@ impl From<YrsValue> for YValue {
|
|
150
146
|
// *yvalue.0
|
151
147
|
// }))),
|
152
148
|
// YrsValue::YMap(val) => YValue::from(RHash::from_iter(val.iter())),
|
153
|
-
v => panic!(
|
154
|
-
"cannot map complex yrs values to yvalue: {}",
|
155
|
-
v.to_string()
|
156
|
-
)
|
149
|
+
v => panic!("cannot map complex yrs values to yvalue: {}", v.to_string()),
|
157
150
|
}
|
158
151
|
}
|
159
152
|
}
|
@@ -215,6 +208,7 @@ impl From<YValue> for Any {
|
|
215
208
|
}
|
216
209
|
}
|
217
210
|
|
211
|
+
#[allow(clippy::from_over_into)]
|
218
212
|
impl Into<Value> for YValue {
|
219
213
|
fn into(self) -> Value {
|
220
214
|
self.0.into_inner()
|