y-rb 0.1.4.beta.1-aarch64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ use crate::yarray::YArray;
2
+ use crate::ymap::YMap;
3
+ use crate::ytext::YText;
4
+ use crate::yxml_element::YXmlElement;
5
+ use crate::yxml_text::YXmlText;
6
+ use magnus::Error;
7
+ use std::cell::RefCell;
8
+ use yrs::updates::decoder::Decode;
9
+ use yrs::updates::encoder::Encode;
10
+ use yrs::{Transaction, Update};
11
+
12
+ #[magnus::wrap(class = "Y::Transaction")]
13
+ pub(crate) struct YTransaction(pub(crate) RefCell<Transaction>);
14
+
15
+ /// SAFETY: This is safe because we only access this data when the GVL is held.
16
+ unsafe impl Send for YTransaction {}
17
+
18
+ impl YTransaction {
19
+ pub(crate) fn ytransaction_apply_update(
20
+ &self,
21
+ update: Vec<u8>
22
+ ) -> Result<(), Error> {
23
+ return Update::decode_v1(update.as_slice())
24
+ .map(|u| self.0.borrow_mut().apply_update(u))
25
+ .map_err(|_e| Error::runtime_error("cannot apply update"));
26
+ }
27
+ pub(crate) fn ytransaction_commit(&self) {
28
+ self.0.borrow_mut().commit();
29
+ }
30
+ pub(crate) fn ytransaction_get_array(&self, name: String) -> YArray {
31
+ let a = self.0.borrow_mut().get_array(&*name);
32
+
33
+ return YArray(RefCell::from(a));
34
+ }
35
+ pub(crate) fn ytransaction_get_map(&self, name: String) -> YMap {
36
+ let m = self.0.borrow_mut().get_map(&*name);
37
+
38
+ return YMap(RefCell::from(m));
39
+ }
40
+ pub(crate) fn ytransaction_get_text(&self, name: String) -> YText {
41
+ let t = self.0.borrow_mut().get_text(&*name);
42
+
43
+ return YText(RefCell::new(t));
44
+ }
45
+ pub(crate) fn ytransaction_get_xml_element(
46
+ &self,
47
+ name: String
48
+ ) -> YXmlElement {
49
+ let el = self.0.borrow_mut().get_xml_element(&*name);
50
+
51
+ return YXmlElement(RefCell::new(el));
52
+ }
53
+ pub(crate) fn ytransaction_get_xml_text(&self, name: String) -> YXmlText {
54
+ let t = self.0.borrow_mut().get_xml_text(&*name);
55
+
56
+ return YXmlText(RefCell::new(t));
57
+ }
58
+ pub(crate) fn ytransaction_state_vector(&self) -> Vec<u8> {
59
+ return self.0.borrow_mut().state_vector().encode_v1();
60
+ }
61
+ }
@@ -0,0 +1,237 @@
1
+ use crate::{YText, YXmlElement, YXmlText};
2
+ use lib0::any::Any;
3
+ use magnus::r_hash::ForEach::Continue;
4
+ use magnus::value::Qnil;
5
+ use magnus::{
6
+ class, Float, Integer, RArray, RHash, RString, Symbol, Value, QNIL
7
+ };
8
+ use std::cell::RefCell;
9
+ use std::collections::HashMap;
10
+ use yrs::types::Value as YrsValue;
11
+ use yrs::{
12
+ Text as YrsText, XmlElement as YrsXmlElement, XmlText as YrsXmlText
13
+ };
14
+
15
+ pub(crate) struct YValue(pub(crate) RefCell<Value>);
16
+
17
+ impl From<Value> for YValue {
18
+ fn from(value: Value) -> Self {
19
+ YValue(RefCell::from(value))
20
+ }
21
+ }
22
+
23
+ impl From<Qnil> for YValue {
24
+ fn from(value: Qnil) -> Self {
25
+ YValue(RefCell::from(Value::from(value)))
26
+ }
27
+ }
28
+
29
+ impl From<bool> for YValue {
30
+ fn from(value: bool) -> Self {
31
+ YValue(RefCell::from(Value::from(value)))
32
+ }
33
+ }
34
+
35
+ impl From<f64> for YValue {
36
+ fn from(value: f64) -> Self {
37
+ YValue(RefCell::from(Value::from(value)))
38
+ }
39
+ }
40
+
41
+ impl From<i64> for YValue {
42
+ fn from(value: i64) -> Self {
43
+ YValue(RefCell::from(Value::from(value)))
44
+ }
45
+ }
46
+
47
+ impl From<u32> for YValue {
48
+ fn from(value: u32) -> Self {
49
+ YValue(RefCell::from(Value::from(value)))
50
+ }
51
+ }
52
+
53
+ impl From<String> for YValue {
54
+ fn from(value: String) -> Self {
55
+ YValue(RefCell::from(Value::from(value)))
56
+ }
57
+ }
58
+
59
+ impl From<RArray> for YValue {
60
+ fn from(value: RArray) -> Self {
61
+ YValue(RefCell::from(Value::from(value)))
62
+ }
63
+ }
64
+
65
+ impl From<RHash> for YValue {
66
+ fn from(value: RHash) -> Self {
67
+ YValue(RefCell::from(Value::from(value)))
68
+ }
69
+ }
70
+
71
+ impl From<YrsText> for YValue {
72
+ fn from(value: YrsText) -> Self {
73
+ YValue(RefCell::from(Value::from(YText(RefCell::from(value)))))
74
+ }
75
+ }
76
+
77
+ impl From<YrsXmlElement> for YValue {
78
+ fn from(value: YrsXmlElement) -> Self {
79
+ YValue(RefCell::from(Value::from(YXmlElement(RefCell::from(
80
+ value
81
+ )))))
82
+ }
83
+ }
84
+
85
+ impl From<YrsXmlText> for YValue {
86
+ fn from(value: YrsXmlText) -> Self {
87
+ YValue(RefCell::from(Value::from(YXmlText(RefCell::from(value)))))
88
+ }
89
+ }
90
+
91
+ impl From<YText> for YValue {
92
+ fn from(value: YText) -> Self {
93
+ YValue(RefCell::from(Value::from(value)))
94
+ }
95
+ }
96
+
97
+ impl From<YXmlElement> for YValue {
98
+ fn from(value: YXmlElement) -> Self {
99
+ YValue(RefCell::from(Value::from(value)))
100
+ }
101
+ }
102
+
103
+ impl From<YXmlText> for YValue {
104
+ fn from(value: YXmlText) -> Self {
105
+ YValue(RefCell::from(Value::from(value)))
106
+ }
107
+ }
108
+
109
+ impl From<Any> for YValue {
110
+ fn from(value: Any) -> Self {
111
+ match value {
112
+ Any::Null => YValue::from(QNIL),
113
+ Any::Undefined => YValue::from(QNIL),
114
+ Any::Bool(v) => YValue::from(v),
115
+ Any::Number(v) => YValue::from(v),
116
+ Any::BigInt(v) => YValue::from(v),
117
+ Any::String(v) => YValue::from(v.into_string()),
118
+ Any::Buffer(v) => YValue::from(Value::from(v.into_vec())),
119
+ Any::Array(v) => {
120
+ let arr = v
121
+ .iter()
122
+ .map(|i| YValue::from(i.clone()))
123
+ .map(|value| *value.0.borrow())
124
+ .collect::<Vec<Value>>();
125
+ YValue::from(RArray::from_vec(arr))
126
+ }
127
+ Any::Map(v) => {
128
+ let map = v
129
+ .iter()
130
+ .map(|(key, val)| {
131
+ let v = val.clone();
132
+ (key.to_string(), YValue::from(v).into())
133
+ })
134
+ .collect::<HashMap<String, Value>>();
135
+ YValue::from(RHash::from_iter(map))
136
+ }
137
+ }
138
+ }
139
+ }
140
+
141
+ impl From<YrsValue> for YValue {
142
+ fn from(value: YrsValue) -> Self {
143
+ match value {
144
+ YrsValue::Any(val) => YValue::from(val),
145
+ YrsValue::YText(text) => YValue::from(text),
146
+ YrsValue::YXmlElement(el) => YValue::from(el),
147
+ YrsValue::YXmlText(text) => YValue::from(text),
148
+ // YrsValue::YArray(val) => YValue::from(RArray::from_vec(val.iter().map(|item| {
149
+ // let yvalue = YValue::from(item);
150
+ // *yvalue.0
151
+ // }))),
152
+ // 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
+ )
157
+ }
158
+ }
159
+ }
160
+
161
+ impl From<YValue> for Any {
162
+ fn from(val: YValue) -> Self {
163
+ let value = val.0.into_inner();
164
+ if value.is_nil() {
165
+ Any::Null
166
+ } else if value.is_kind_of(class::float()) {
167
+ let f = Float::from_value(value).unwrap();
168
+ Any::Number(f.to_f64())
169
+ } else if value.is_kind_of(class::integer()) {
170
+ let i = Integer::from_value(value).unwrap();
171
+ Any::BigInt(i.to_i64().unwrap())
172
+ } else if value.is_kind_of(class::symbol()) {
173
+ let s = Symbol::from_value(value).unwrap();
174
+ Any::String(Box::from(s.name().unwrap()))
175
+ } else if value.is_kind_of(class::true_class()) {
176
+ Any::Bool(true)
177
+ } else if value.is_kind_of(class::false_class()) {
178
+ Any::Bool(false)
179
+ } else if value.is_kind_of(class::string()) {
180
+ let s = RString::from_value(value).unwrap();
181
+ unsafe { Any::String(Box::from(s.as_str().unwrap().to_string())) }
182
+ } else if value.is_kind_of(class::array()) {
183
+ let arr = RArray::from_value(value).unwrap();
184
+ let items = arr
185
+ .each()
186
+ .map(|item| {
187
+ let yvalue = YValue::from(item.unwrap());
188
+ Any::from(yvalue)
189
+ })
190
+ .collect::<Vec<Any>>();
191
+ Any::Array(Box::from(items))
192
+ } else if value.is_kind_of(class::hash()) {
193
+ let map = RHash::from_value(value).unwrap();
194
+ let mut m: HashMap<String, Any> = HashMap::new();
195
+
196
+ // we need to map symbol keys to strings, because we can't store
197
+ // symbols in any of the yrs data structures
198
+ map.foreach(|key: Value, val: Value| {
199
+ let k = if let Some(converted_key) = Symbol::from_value(key) {
200
+ converted_key.to_string()
201
+ } else {
202
+ let converted_key = RString::from_value(key).unwrap();
203
+ let result = converted_key.to_string();
204
+ result.unwrap()
205
+ };
206
+ m.insert(k, Any::from(YValue::from(val)));
207
+ Ok(Continue)
208
+ })
209
+ .expect("cannot map key/value pair");
210
+
211
+ Any::Map(Box::from(m))
212
+ } else {
213
+ Any::Undefined
214
+ }
215
+ }
216
+ }
217
+
218
+ impl Into<Value> for YValue {
219
+ fn into(self) -> Value {
220
+ self.0.into_inner()
221
+ }
222
+ }
223
+
224
+ #[cfg(test)]
225
+ mod tests {
226
+ use crate::yvalue::YValue;
227
+ use lib0::any::Any;
228
+
229
+ #[test]
230
+ fn convert_any_to_yvalue() {
231
+ let _cleanup = unsafe { magnus::embed::init() };
232
+ let value = Any::Null;
233
+ let yvalue: YValue = value.into();
234
+
235
+ assert!(yvalue.0.into_inner().is_nil());
236
+ }
237
+ }
@@ -0,0 +1,228 @@
1
+ use crate::yvalue::YValue;
2
+ use crate::yxml_text::YXmlText;
3
+ use crate::YTransaction;
4
+ use magnus::block::Proc;
5
+ use magnus::{Error, RArray, RHash, Symbol, Value};
6
+ use std::cell::RefCell;
7
+ use yrs::types::Change;
8
+ use yrs::{Xml, XmlElement};
9
+
10
+ #[magnus::wrap(class = "Y::XMLElement")]
11
+ pub(crate) struct YXmlElement(pub(crate) RefCell<XmlElement>);
12
+
13
+ /// SAFETY: This is safe because we only access this data when the GVL is held.
14
+ unsafe impl Send for YXmlElement {}
15
+
16
+ impl YXmlElement {
17
+ pub(crate) fn yxml_element_attributes(&self) -> RHash {
18
+ RHash::from_iter(self.0.borrow().attributes().into_iter())
19
+ }
20
+ pub(crate) fn yxml_element_first_child(&self) -> Option<Value> {
21
+ self.yxml_element_get(0)
22
+ }
23
+ pub(crate) fn yxml_element_get(&self, index: u32) -> Option<Value> {
24
+ self.0.borrow().get(index).map(|node| match node {
25
+ Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
26
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
27
+ })
28
+ }
29
+ pub(crate) fn yxml_element_get_attribute(
30
+ &self,
31
+ name: String
32
+ ) -> Option<String> {
33
+ self.0.borrow().get_attribute(&*name)
34
+ }
35
+ pub(crate) fn yxml_element_insert_attribute(
36
+ &self,
37
+ transaction: &YTransaction,
38
+ name: String,
39
+ value: String
40
+ ) {
41
+ self.0.borrow_mut().insert_attribute(
42
+ &mut *transaction.0.borrow_mut(),
43
+ name,
44
+ value
45
+ );
46
+ }
47
+ pub(crate) fn yxml_element_insert_element(
48
+ &self,
49
+ transaction: &YTransaction,
50
+ index: u32,
51
+ name: String
52
+ ) {
53
+ self.0.borrow_mut().insert_elem(
54
+ &mut *transaction.0.borrow_mut(),
55
+ index,
56
+ name
57
+ );
58
+ }
59
+ pub(crate) fn yxml_element_insert_text(
60
+ &self,
61
+ transaction: &YTransaction,
62
+ index: u32
63
+ ) {
64
+ self.0
65
+ .borrow_mut()
66
+ .insert_text(&mut *transaction.0.borrow_mut(), index);
67
+ }
68
+ pub(crate) fn yxml_element_next_sibling(&self) -> Option<Value> {
69
+ self.0.borrow().next_sibling().map(|item| match item {
70
+ Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
71
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
72
+ })
73
+ }
74
+ pub(crate) fn yxml_element_observe(
75
+ &self,
76
+ block: Proc
77
+ ) -> Result<u32, Error> {
78
+ let change_added = Symbol::new("added").to_static();
79
+ let change_retain = Symbol::new("retain").to_static();
80
+ let change_removed = Symbol::new("removed").to_static();
81
+
82
+ let subscription_id = self.0.borrow_mut().observe(
83
+ move |transaction, xml_element_event| {
84
+ let delta = xml_element_event.delta(transaction);
85
+ let changes = RArray::with_capacity(delta.len());
86
+
87
+ for change in delta {
88
+ match change {
89
+ Change::Added(v) => {
90
+ let values = v
91
+ .iter()
92
+ .map(|o| YValue::from(o.clone()))
93
+ .map(|o| *o.0.borrow())
94
+ .collect::<Vec<_>>();
95
+
96
+ let payload = RHash::new();
97
+ payload
98
+ .aset(change_added, RArray::from_vec(values))
99
+ .expect("cannot create change::added payload");
100
+
101
+ changes.push(payload).expect(
102
+ "cannot push payload to list of changes"
103
+ );
104
+ }
105
+ Change::Retain(position) => {
106
+ let payload = RHash::new();
107
+ payload
108
+ .aset(change_retain, *position)
109
+ .expect("cannot create change::retain payload");
110
+
111
+ changes.push(payload).expect(
112
+ "cannot push payload to list of changes"
113
+ );
114
+ }
115
+ Change::Removed(position) => {
116
+ let payload = RHash::new();
117
+ payload.aset(change_removed, *position).expect(
118
+ "cannot create change::removed payload"
119
+ );
120
+
121
+ changes.push(payload).expect(
122
+ "cannot push payload to list of changes"
123
+ );
124
+ }
125
+ }
126
+ }
127
+
128
+ block
129
+ .call::<(RArray,), Value>((changes,))
130
+ .expect("cannot call block");
131
+ }
132
+ );
133
+
134
+ Ok(subscription_id.into())
135
+ }
136
+ pub(crate) fn yxml_element_parent(&self) -> Option<Value> {
137
+ self.0
138
+ .borrow()
139
+ .parent()
140
+ .map(|item| Value::from(YXmlElement(RefCell::from(item))))
141
+ }
142
+ pub(crate) fn yxml_element_prev_sibling(&self) -> Option<Value> {
143
+ self.0.borrow().prev_sibling().map(|item| match item {
144
+ Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
145
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
146
+ })
147
+ }
148
+ pub(crate) fn yxml_element_push_element_back(
149
+ &self,
150
+ transaction: &YTransaction,
151
+ name: String
152
+ ) -> YXmlElement {
153
+ let xml_element = self
154
+ .0
155
+ .borrow_mut()
156
+ .push_elem_back(&mut *transaction.0.borrow_mut(), name);
157
+
158
+ YXmlElement(RefCell::from(xml_element))
159
+ }
160
+ pub(crate) fn yxml_element_push_element_front(
161
+ &self,
162
+ transaction: &YTransaction,
163
+ name: String
164
+ ) -> YXmlElement {
165
+ let xml_element = self
166
+ .0
167
+ .borrow_mut()
168
+ .push_elem_front(&mut *transaction.0.borrow_mut(), name);
169
+
170
+ YXmlElement(RefCell::from(xml_element))
171
+ }
172
+ pub(crate) fn yxml_element_push_text_back(
173
+ &self,
174
+ transaction: &YTransaction
175
+ ) -> YXmlText {
176
+ let xml_text = self
177
+ .0
178
+ .borrow_mut()
179
+ .push_text_back(&mut *transaction.0.borrow_mut());
180
+
181
+ YXmlText(RefCell::from(xml_text))
182
+ }
183
+ pub(crate) fn yxml_element_push_text_front(
184
+ &self,
185
+ transaction: &YTransaction
186
+ ) -> YXmlText {
187
+ let xml_text = self
188
+ .0
189
+ .borrow_mut()
190
+ .push_text_front(&mut *transaction.0.borrow_mut());
191
+
192
+ YXmlText(RefCell::from(xml_text))
193
+ }
194
+ pub(crate) fn yxml_element_remove_attribute(
195
+ &self,
196
+ transaction: &YTransaction,
197
+ name: String
198
+ ) {
199
+ self.0.borrow_mut().remove_attribute::<&str>(
200
+ &mut *transaction.0.borrow_mut(),
201
+ &name.as_str()
202
+ );
203
+ }
204
+ pub(crate) fn yxml_element_remove_range(
205
+ &self,
206
+ transaction: &YTransaction,
207
+ index: u32,
208
+ length: u32
209
+ ) {
210
+ self.0.borrow_mut().remove_range(
211
+ &mut *transaction.0.borrow_mut(),
212
+ index,
213
+ length
214
+ );
215
+ }
216
+ pub(crate) fn yxml_element_size(&self) -> u32 {
217
+ self.0.borrow().len()
218
+ }
219
+ pub(crate) fn yxml_element_tag(&self) -> String {
220
+ self.0.borrow().tag().to_string()
221
+ }
222
+ pub(crate) fn yxml_element_to_s(&self) -> String {
223
+ self.0.borrow().to_string()
224
+ }
225
+ pub(crate) fn yxml_element_unobserve(&self, subscription_id: u32) {
226
+ self.0.borrow_mut().unobserve(subscription_id);
227
+ }
228
+ }
@@ -0,0 +1,157 @@
1
+ use crate::utils::map_rhash_to_attrs;
2
+ use crate::yvalue::YValue;
3
+ use crate::{YTransaction, YXmlElement};
4
+ use lib0::any::Any;
5
+ use magnus::{Error, RHash, Value};
6
+ use std::cell::RefCell;
7
+ use yrs::{Xml, XmlText};
8
+
9
+ #[magnus::wrap(class = "Y::XMLText")]
10
+ pub(crate) struct YXmlText(pub(crate) RefCell<XmlText>);
11
+
12
+ /// SAFETY: This is safe because we only access this data when the GVL is held.
13
+ unsafe impl Send for YXmlText {}
14
+
15
+ impl YXmlText {
16
+ pub(crate) fn yxml_text_attributes(&self) -> RHash {
17
+ RHash::from_iter(self.0.borrow().attributes().into_iter())
18
+ }
19
+ pub(crate) fn yxml_text_format(
20
+ &self,
21
+ transaction: &YTransaction,
22
+ index: u32,
23
+ length: u32,
24
+ attrs: RHash
25
+ ) -> Result<(), Error> {
26
+ map_rhash_to_attrs(attrs).map(|a| {
27
+ self.0.borrow_mut().format(
28
+ &mut *transaction.0.borrow_mut(),
29
+ index,
30
+ length,
31
+ a
32
+ );
33
+ })
34
+ }
35
+ pub(crate) fn yxml_text_get_attribute(
36
+ &self,
37
+ name: String
38
+ ) -> Option<String> {
39
+ self.0.borrow().get_attribute(&*name)
40
+ }
41
+ pub(crate) fn yxml_text_insert(
42
+ &self,
43
+ transaction: &YTransaction,
44
+ index: u32,
45
+ content: String
46
+ ) {
47
+ self.0.borrow_mut().insert(
48
+ &mut *transaction.0.borrow_mut(),
49
+ index,
50
+ &*content
51
+ )
52
+ }
53
+ pub(crate) fn yxml_text_insert_attribute(
54
+ &self,
55
+ transaction: &YTransaction,
56
+ name: String,
57
+ value: String
58
+ ) {
59
+ self.0.borrow_mut().insert_attribute(
60
+ &mut *transaction.0.borrow_mut(),
61
+ name,
62
+ value
63
+ )
64
+ }
65
+ pub(crate) fn yxml_text_insert_embed_with_attributes(
66
+ &self,
67
+ transaction: &YTransaction,
68
+ index: u32,
69
+ content: Value,
70
+ attrs: RHash
71
+ ) -> Result<(), Error> {
72
+ let yvalue = YValue::from(content);
73
+ let avalue = Any::from(yvalue);
74
+
75
+ map_rhash_to_attrs(attrs).map(|a| {
76
+ self.0.borrow_mut().insert_embed_with_attributes(
77
+ &mut *transaction.0.borrow_mut(),
78
+ index,
79
+ avalue,
80
+ a
81
+ );
82
+ })
83
+ }
84
+ pub(crate) fn yxml_text_insert_embed(
85
+ &self,
86
+ transaction: &YTransaction,
87
+ index: u32,
88
+ embed: Value
89
+ ) {
90
+ self.0.borrow_mut().insert_embed(
91
+ &mut *transaction.0.borrow_mut(),
92
+ index,
93
+ Any::from(YValue::from(embed))
94
+ )
95
+ }
96
+ pub(crate) fn yxml_text_insert_with_attributes(
97
+ &self,
98
+ transaction: &YTransaction,
99
+ index: u32,
100
+ content: String,
101
+ attrs: RHash
102
+ ) -> Result<(), Error> {
103
+ map_rhash_to_attrs(attrs).map(|a| {
104
+ self.0.borrow_mut().insert_with_attributes(
105
+ &mut *transaction.0.borrow_mut(),
106
+ index,
107
+ &*content,
108
+ a
109
+ );
110
+ })
111
+ }
112
+ pub(crate) fn yxml_text_length(&self) -> u32 {
113
+ self.0.borrow().len()
114
+ }
115
+ pub(crate) fn yxml_text_next_sibling(&self) -> Option<Value> {
116
+ self.0.borrow().next_sibling().map(|item| match item {
117
+ Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
118
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
119
+ })
120
+ }
121
+ pub(crate) fn yxml_text_parent(&self) -> Option<Value> {
122
+ self.0
123
+ .borrow()
124
+ .parent()
125
+ .map(|item| Value::from(YXmlElement(RefCell::from(item))))
126
+ }
127
+ pub(crate) fn yxml_text_prev_sibling(&self) -> Option<Value> {
128
+ self.0.borrow().prev_sibling().map(|item| match item {
129
+ Xml::Element(el) => Value::from(YXmlElement(RefCell::from(el))),
130
+ Xml::Text(text) => Value::from(YXmlText(RefCell::from(text)))
131
+ })
132
+ }
133
+ pub(crate) fn yxml_text_push(
134
+ &self,
135
+ transaction: &YTransaction,
136
+ content: String
137
+ ) {
138
+ self.0
139
+ .borrow_mut()
140
+ .push(&mut *transaction.0.borrow_mut(), &*content)
141
+ }
142
+ pub(crate) fn yxml_text_remove_range(
143
+ &self,
144
+ transaction: &YTransaction,
145
+ index: u32,
146
+ length: u32
147
+ ) {
148
+ self.0.borrow_mut().remove_range(
149
+ &mut *transaction.0.borrow_mut(),
150
+ index,
151
+ length
152
+ );
153
+ }
154
+ pub(crate) fn yxml_text_to_s(&self) -> String {
155
+ self.0.borrow().to_string()
156
+ }
157
+ }
data/lib/2.7/yrb.so ADDED
Binary file
data/lib/3.0/yrb.so ADDED
Binary file
data/lib/3.1/yrb.so ADDED
Binary file