Skip to main content

json_glib/auto/
node.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi,Array,NodeType,Object};
7use glib::{translate::*};
8
9glib::wrapper! {
10    /// A generic container of JSON data types.
11    ///
12    /// `JsonNode` can contain fundamental types (integers, booleans, floating point
13    /// numbers, strings) and complex types (arrays and objects).
14    ///
15    /// When parsing a JSON data stream you extract the root node and walk
16    /// the node tree by retrieving the type of data contained inside the
17    /// node with the `JSON_NODE_TYPE` macro. If the node contains a fundamental
18    /// type you can retrieve a copy of the `GValue` holding it with the
19    /// [`value()`][Self::value()] function, and then use the `GValue` API to extract
20    /// the data; if the node contains a complex type you can retrieve the
21    /// [`Object`][crate::Object] or the [`Array`][crate::Array] using [`object()`][Self::object()]
22    /// or [`array()`][Self::array()] respectively, and then retrieve the nodes
23    /// they contain.
24    ///
25    /// A `JsonNode` may be marked as immutable using [`seal()`][Self::seal()]. This
26    /// marks the node and all its descendents as read-only, and means that
27    /// subsequent calls to setter functions (such as [`set_array()`][Self::set_array()])
28    /// on them will abort as a programmer error. By marking a node tree as
29    /// immutable, it may be referenced in multiple places and its hash value cached
30    /// for fast lookups, without the possibility of a value deep within the tree
31    /// changing and affecting hash values. Immutable nodes may be passed to
32    /// functions which retain a reference to them without needing to take a copy.
33    ///
34    /// A `JsonNode` supports two types of memory management: `malloc`/`free`
35    /// semantics, and reference counting semantics. The two may be mixed to a
36    /// limited extent: nodes may be allocated (which gives them a reference count
37    /// of 1), referenced one or more times, unreferenced exactly that number of
38    /// times (using `Json::Node::unref()`), then either unreferenced exactly
39    /// once more or freed (using `Json::Node::free()`) to destroy them.
40    /// The `Json::Node::free()` function must not be used when a node might
41    /// have a reference count not equal to 1. To this end, JSON-GLib uses
42    /// `Json::Node::copy()` and `Json::Node::unref()` internally.
43    #[derive(Debug, PartialOrd, Ord)]
44    pub struct Node(Shared<ffi::JsonNode>);
45
46    match fn {
47        ref => |ptr| ffi::json_node_ref(ptr),
48        unref => |ptr| ffi::json_node_unref(ptr),
49        type_ => || ffi::json_node_get_type(),
50    }
51}
52
53impl Node {
54    /// Allocates a new, uninitialized node.
55    ///
56    /// Use [`init()`][Self::init()] and its variants to initialize the returned value.
57    ///
58    /// # Returns
59    ///
60    /// the newly allocated node
61    #[doc(alias = "json_node_alloc")]
62    pub fn alloc() -> Node {
63        assert_initialized_main_thread!();
64        unsafe {
65            from_glib_full(ffi::json_node_alloc())
66        }
67    }
68
69    /// Creates a new node holding the given @type_.
70    ///
71    /// This is a convenience function for `Json::Node::alloc()` and
72    /// [`init()`][Self::init()], and it's the equivalent of:
73    ///
74    /// **⚠️ The following code is in c ⚠️**
75    ///
76    /// ```c
77    ///    json_node_init (json_node_alloc (), type);
78    /// ```
79    /// ## `type_`
80    /// the type of the node to create
81    ///
82    /// # Returns
83    ///
84    /// the newly created node
85    #[doc(alias = "json_node_new")]
86    pub fn new(type_: NodeType) -> Node {
87        assert_initialized_main_thread!();
88        unsafe {
89            from_glib_full(ffi::json_node_new(type_.into_glib()))
90        }
91    }
92
93    #[doc(alias = "json_node_copy")]
94#[must_use]
95    pub fn copy(&self) -> Node {
96        unsafe {
97            from_glib_full(ffi::json_node_copy(self.to_glib_none().0))
98        }
99    }
100
101    /// Retrieves the JSON array inside @self.
102    ///
103    /// The reference count of the returned array is increased.
104    ///
105    /// It is a programmer error to call this on a node which doesn’t hold an
106    /// array value. Use `JSON_NODE_HOLDS_ARRAY` first.
107    ///
108    /// # Returns
109    ///
110    /// the JSON array with its reference
111    ///   count increased.
112    #[doc(alias = "json_node_dup_array")]
113    pub fn dup_array(&self) -> Option<Array> {
114        unsafe {
115            from_glib_full(ffi::json_node_dup_array(self.to_glib_none().0))
116        }
117    }
118
119    /// Retrieves the object inside @self.
120    ///
121    /// The reference count of the returned object is increased.
122    ///
123    /// It is a programmer error to call this on a node which doesn’t hold an
124    /// object value. Use `JSON_NODE_HOLDS_OBJECT` first.
125    ///
126    /// # Returns
127    ///
128    /// the JSON object
129    #[doc(alias = "json_node_dup_object")]
130    pub fn dup_object(&self) -> Option<Object> {
131        unsafe {
132            from_glib_full(ffi::json_node_dup_object(self.to_glib_none().0))
133        }
134    }
135
136    /// Gets a copy of the string value stored inside a node.
137    ///
138    /// If the node does not hold a string value, `NULL` is returned.
139    ///
140    /// # Returns
141    ///
142    /// a copy of the string
143    ///   inside the node
144    #[doc(alias = "json_node_dup_string")]
145    pub fn dup_string(&self) -> Option<glib::GString> {
146        unsafe {
147            from_glib_full(ffi::json_node_dup_string(self.to_glib_none().0))
148        }
149    }
150
151    #[cfg(feature = "v1_2")]
152    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
153    #[doc(alias = "json_node_equal")]
154     fn equal(&self, b: &Node) -> bool {
155        unsafe {
156            from_glib(ffi::json_node_equal(ToGlibPtr::<*mut ffi::JsonNode>::to_glib_none(self).0 as glib::ffi::gconstpointer, ToGlibPtr::<*mut ffi::JsonNode>::to_glib_none(b).0 as glib::ffi::gconstpointer))
157        }
158    }
159
160    /// Retrieves the JSON array stored inside a node.
161    ///
162    /// It is a programmer error to call this on a node which doesn’t hold an
163    /// array value. Use `JSON_NODE_HOLDS_ARRAY` first.
164    ///
165    /// # Returns
166    ///
167    /// the JSON array
168    #[doc(alias = "json_node_get_array")]
169    #[doc(alias = "get_array")]
170    pub fn array(&self) -> Option<Array> {
171        unsafe {
172            from_glib_none(ffi::json_node_get_array(self.to_glib_none().0))
173        }
174    }
175
176    /// Gets the boolean value stored inside a node.
177    ///
178    /// If the node holds an integer or double value which is zero, `FALSE` is
179    /// returned; otherwise `TRUE` is returned.
180    ///
181    /// If the node holds a `JSON_NODE_NULL` value or a value of another
182    /// non-boolean type, `FALSE` is returned.
183    ///
184    /// # Returns
185    ///
186    /// a boolean value.
187    #[doc(alias = "json_node_get_boolean")]
188    #[doc(alias = "get_boolean")]
189    pub fn is_boolean(&self) -> bool {
190        unsafe {
191            from_glib(ffi::json_node_get_boolean(self.to_glib_none().0))
192        }
193    }
194
195    /// Gets the double value stored inside a node.
196    ///
197    /// If the node holds an integer value, it is returned as a double.
198    ///
199    /// If the node holds a `FALSE` boolean value, `0.0` is returned; otherwise
200    /// a non-zero double is returned.
201    ///
202    /// If the node holds a `JSON_NODE_NULL` value or a value of another
203    /// non-double type, `0.0` is returned.
204    ///
205    /// # Returns
206    ///
207    /// a double value.
208    #[doc(alias = "json_node_get_double")]
209    #[doc(alias = "get_double")]
210    pub fn double(&self) -> f64 {
211        unsafe {
212            ffi::json_node_get_double(self.to_glib_none().0)
213        }
214    }
215
216    /// Gets the integer value stored inside a node.
217    ///
218    /// If the node holds a double value, its integer component is returned.
219    ///
220    /// If the node holds a `FALSE` boolean value, `0` is returned; otherwise,
221    /// a non-zero integer is returned.
222    ///
223    /// If the node holds a `JSON_NODE_NULL` value or a value of another
224    /// non-integer type, `0` is returned.
225    ///
226    /// # Returns
227    ///
228    /// an integer value.
229    #[doc(alias = "json_node_get_int")]
230    #[doc(alias = "get_int")]
231    pub fn int(&self) -> i64 {
232        unsafe {
233            ffi::json_node_get_int(self.to_glib_none().0)
234        }
235    }
236
237    /// Retrieves the type of a @self.
238    ///
239    /// # Returns
240    ///
241    /// the type of the node
242    #[doc(alias = "json_node_get_node_type")]
243    #[doc(alias = "get_node_type")]
244    pub fn node_type(&self) -> NodeType {
245        unsafe {
246            from_glib(ffi::json_node_get_node_type(self.to_glib_none().0))
247        }
248    }
249
250    /// Retrieves the object stored inside a node.
251    ///
252    /// It is a programmer error to call this on a node which doesn’t hold an
253    /// object value. Use `JSON_NODE_HOLDS_OBJECT` first.
254    ///
255    /// # Returns
256    ///
257    /// the JSON object
258    #[doc(alias = "json_node_get_object")]
259    #[doc(alias = "get_object")]
260    pub fn object(&self) -> Option<Object> {
261        unsafe {
262            from_glib_none(ffi::json_node_get_object(self.to_glib_none().0))
263        }
264    }
265
266    /// Retrieves the parent node of the given @self.
267    ///
268    /// # Returns
269    ///
270    /// the parent node, or `NULL` if @self
271    ///   is the root node
272    #[doc(alias = "json_node_get_parent")]
273    #[doc(alias = "get_parent")]
274#[must_use]
275    pub fn parent(&self) -> Option<Node> {
276        unsafe {
277            from_glib_none(ffi::json_node_get_parent(self.to_glib_none().0))
278        }
279    }
280
281    /// Gets the string value stored inside a node.
282    ///
283    /// If the node does not hold a string value, `NULL` is returned.
284    ///
285    /// # Returns
286    ///
287    /// a string value.
288    #[doc(alias = "json_node_get_string")]
289    #[doc(alias = "get_string")]
290    pub fn string(&self) -> Option<glib::GString> {
291        unsafe {
292            from_glib_none(ffi::json_node_get_string(self.to_glib_none().0))
293        }
294    }
295
296    /// Retrieves a value from a node and copies into @value.
297    ///
298    /// When done using it, call `g_value_unset()` on the `GValue` to free the
299    /// associated resources.
300    ///
301    /// It is a programmer error to call this on a node which doesn’t hold a scalar
302    /// value. Use `JSON_NODE_HOLDS_VALUE` first.
303    ///
304    /// # Returns
305    ///
306    ///
307    /// ## `value`
308    /// return location for an uninitialized value
309    #[doc(alias = "json_node_get_value")]
310    #[doc(alias = "get_value")]
311    pub fn value(&self) -> glib::Value {
312        unsafe {
313            let mut value = glib::Value::uninitialized();
314            ffi::json_node_get_value(self.to_glib_none().0, value.to_glib_none_mut().0);
315            value
316        }
317    }
318
319    /// Returns the `GType` of the payload of the node.
320    ///
321    /// For `JSON_NODE_NULL` nodes, the returned type is `G_TYPE_INVALID`.
322    ///
323    /// # Returns
324    ///
325    /// the type for the payload
326    #[doc(alias = "json_node_get_value_type")]
327    #[doc(alias = "get_value_type")]
328    pub fn value_type(&self) -> glib::types::Type {
329        unsafe {
330            from_glib(ffi::json_node_get_value_type(self.to_glib_none().0))
331        }
332    }
333
334    #[cfg(feature = "v1_2")]
335    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
336    #[doc(alias = "json_node_hash")]
337     fn hash(&self) -> u32 {
338        unsafe {
339            ffi::json_node_hash(ToGlibPtr::<*mut ffi::JsonNode>::to_glib_none(self).0 as glib::ffi::gconstpointer)
340        }
341    }
342
343    /// Initializes a @self to a specific @type_.
344    ///
345    /// If the node has already been initialized once, it will be reset to
346    /// the given type, and any data contained will be cleared.
347    /// ## `type_`
348    /// the type of JSON node to initialize @self to
349    ///
350    /// # Returns
351    ///
352    /// the initialized node
353    #[doc(alias = "json_node_init")]
354#[must_use]
355    pub fn init(&self, type_: NodeType) -> Node {
356        unsafe {
357            from_glib_none(ffi::json_node_init(self.to_glib_none().0, type_.into_glib()))
358        }
359    }
360
361    /// Initializes @self to `JSON_NODE_ARRAY` and sets @array into it.
362    ///
363    /// This function will take a reference on @array.
364    ///
365    /// If the node has already been initialized once, it will be reset to
366    /// the given type, and any data contained will be cleared.
367    /// ## `array`
368    /// the JSON array to initialize @self with, or `NULL`
369    ///
370    /// # Returns
371    ///
372    /// the initialized node
373    #[doc(alias = "json_node_init_array")]
374#[must_use]
375    pub fn init_array(&self, array: Option<&Array>) -> Node {
376        unsafe {
377            from_glib_none(ffi::json_node_init_array(self.to_glib_none().0, array.to_glib_none().0))
378        }
379    }
380
381    /// Initializes @self to `JSON_NODE_VALUE` and sets @value into it.
382    ///
383    /// If the node has already been initialized once, it will be reset to
384    /// the given type, and any data contained will be cleared.
385    /// ## `value`
386    /// a boolean value
387    ///
388    /// # Returns
389    ///
390    /// the initialized node
391    #[doc(alias = "json_node_init_boolean")]
392#[must_use]
393    pub fn init_boolean(&self, value: bool) -> Node {
394        unsafe {
395            from_glib_none(ffi::json_node_init_boolean(self.to_glib_none().0, value.into_glib()))
396        }
397    }
398
399    /// Initializes @self to `JSON_NODE_VALUE` and sets @value into it.
400    ///
401    /// If the node has already been initialized once, it will be reset to
402    /// the given type, and any data contained will be cleared.
403    /// ## `value`
404    /// a floating point value
405    ///
406    /// # Returns
407    ///
408    /// the initialized node
409    #[doc(alias = "json_node_init_double")]
410#[must_use]
411    pub fn init_double(&self, value: f64) -> Node {
412        unsafe {
413            from_glib_none(ffi::json_node_init_double(self.to_glib_none().0, value))
414        }
415    }
416
417    /// Initializes @self to `JSON_NODE_VALUE` and sets @value into it.
418    ///
419    /// If the node has already been initialized once, it will be reset to
420    /// the given type, and any data contained will be cleared.
421    /// ## `value`
422    /// an integer
423    ///
424    /// # Returns
425    ///
426    /// the initialized node
427    #[doc(alias = "json_node_init_int")]
428#[must_use]
429    pub fn init_int(&self, value: i64) -> Node {
430        unsafe {
431            from_glib_none(ffi::json_node_init_int(self.to_glib_none().0, value))
432        }
433    }
434
435    /// Initializes @self to `JSON_NODE_NULL`.
436    ///
437    /// If the node has already been initialized once, it will be reset to
438    /// the given type, and any data contained will be cleared.
439    ///
440    /// # Returns
441    ///
442    /// the initialized node
443    #[doc(alias = "json_node_init_null")]
444#[must_use]
445    pub fn init_null(&self) -> Node {
446        unsafe {
447            from_glib_none(ffi::json_node_init_null(self.to_glib_none().0))
448        }
449    }
450
451    /// Initializes @self to `JSON_NODE_OBJECT` and sets @object into it.
452    ///
453    /// This function will take a reference on @object.
454    ///
455    /// If the node has already been initialized once, it will be reset to
456    /// the given type, and any data contained will be cleared.
457    /// ## `object`
458    /// the JSON object to initialize @self with, or `NULL`
459    ///
460    /// # Returns
461    ///
462    /// the initialized node
463    #[doc(alias = "json_node_init_object")]
464#[must_use]
465    pub fn init_object(&self, object: Option<&Object>) -> Node {
466        unsafe {
467            from_glib_none(ffi::json_node_init_object(self.to_glib_none().0, object.to_glib_none().0))
468        }
469    }
470
471    /// Initializes @self to `JSON_NODE_VALUE` and sets @value into it.
472    ///
473    /// If the node has already been initialized once, it will be reset to
474    /// the given type, and any data contained will be cleared.
475    /// ## `value`
476    /// a string value
477    ///
478    /// # Returns
479    ///
480    /// the initialized node
481    #[doc(alias = "json_node_init_string")]
482#[must_use]
483    pub fn init_string(&self, value: Option<&str>) -> Node {
484        unsafe {
485            from_glib_none(ffi::json_node_init_string(self.to_glib_none().0, value.to_glib_none().0))
486        }
487    }
488
489    /// Check whether the given @self has been marked as immutable by calling
490    /// [`seal()`][Self::seal()] on it.
491    ///
492    /// # Returns
493    ///
494    /// `TRUE` if the @self is immutable
495    #[cfg(feature = "v1_2")]
496    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
497    #[doc(alias = "json_node_is_immutable")]
498    pub fn is_immutable(&self) -> bool {
499        unsafe {
500            from_glib(ffi::json_node_is_immutable(self.to_glib_none().0))
501        }
502    }
503
504    /// Checks whether @self is a `JSON_NODE_NULL`.
505    ///
506    /// A `JSON_NODE_NULL` node is not the same as a `NULL` node; a `JSON_NODE_NULL`
507    /// represents a literal `null` value in the JSON tree.
508    ///
509    /// # Returns
510    ///
511    /// `TRUE` if the node is null
512    #[doc(alias = "json_node_is_null")]
513    pub fn is_null(&self) -> bool {
514        unsafe {
515            from_glib(ffi::json_node_is_null(self.to_glib_none().0))
516        }
517    }
518
519    /// Seals the given node, making it immutable to further changes.
520    ///
521    /// In order to be sealed, the @self must have a type and value set. The value
522    /// will be recursively sealed — if the node holds an object, that JSON object
523    /// will be sealed, etc.
524    ///
525    /// If the `node` is already immutable, this is a no-op.
526    #[cfg(feature = "v1_2")]
527    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
528    #[doc(alias = "json_node_seal")]
529    pub fn seal(&self) {
530        unsafe {
531            ffi::json_node_seal(self.to_glib_none().0);
532        }
533    }
534
535    /// Sets @array inside @self.
536    ///
537    /// The reference count of @array is increased.
538    ///
539    /// It is a programmer error to call this on a node which doesn’t hold an
540    /// array value. Use `JSON_NODE_HOLDS_ARRAY` first.
541    /// ## `array`
542    /// a JSON array
543    #[doc(alias = "json_node_set_array")]
544    pub fn set_array(&self, array: &Array) {
545        unsafe {
546            ffi::json_node_set_array(self.to_glib_none().0, array.to_glib_none().0);
547        }
548    }
549
550    /// Sets @value as the boolean content of the @self, replacing any existing
551    /// content.
552    ///
553    /// It is an error to call this on an immutable node, or on a node which is not
554    /// a value node.
555    /// ## `value`
556    /// a boolean value
557    #[doc(alias = "json_node_set_boolean")]
558    pub fn set_boolean(&self, value: bool) {
559        unsafe {
560            ffi::json_node_set_boolean(self.to_glib_none().0, value.into_glib());
561        }
562    }
563
564    /// Sets @value as the double content of the @self, replacing any existing
565    /// content.
566    ///
567    /// It is an error to call this on an immutable node, or on a node which is not
568    /// a value node.
569    /// ## `value`
570    /// a double value
571    #[doc(alias = "json_node_set_double")]
572    pub fn set_double(&self, value: f64) {
573        unsafe {
574            ffi::json_node_set_double(self.to_glib_none().0, value);
575        }
576    }
577
578    /// Sets @value as the integer content of the @self, replacing any existing
579    /// content.
580    ///
581    /// It is an error to call this on an immutable node, or on a node which is not
582    /// a value node.
583    /// ## `value`
584    /// an integer value
585    #[doc(alias = "json_node_set_int")]
586    pub fn set_int(&self, value: i64) {
587        unsafe {
588            ffi::json_node_set_int(self.to_glib_none().0, value);
589        }
590    }
591
592    /// Sets @objects inside @self.
593    ///
594    /// The reference count of @object is increased.
595    ///
596    /// If @object is `NULL`, the node’s existing object is cleared.
597    ///
598    /// It is an error to call this on an immutable node, or on a node which is not
599    /// an object node.
600    /// ## `object`
601    /// a JSON object
602    #[doc(alias = "json_node_set_object")]
603    pub fn set_object(&self, object: Option<&Object>) {
604        unsafe {
605            ffi::json_node_set_object(self.to_glib_none().0, object.to_glib_none().0);
606        }
607    }
608
609    /// Sets the parent node for the given `node`.
610    ///
611    /// It is an error to call this with an immutable @parent.
612    ///
613    /// The @self may be immutable.
614    /// ## `parent`
615    /// the parent node
616    #[doc(alias = "json_node_set_parent")]
617    pub fn set_parent(&self, parent: Option<&Node>) {
618        unsafe {
619            ffi::json_node_set_parent(self.to_glib_none().0, parent.to_glib_none().0);
620        }
621    }
622
623    /// Sets @value as the string content of the @self, replacing any existing
624    /// content.
625    ///
626    /// It is an error to call this on an immutable node, or on a node which is not
627    /// a value node.
628    /// ## `value`
629    /// a string value
630    #[doc(alias = "json_node_set_string")]
631    pub fn set_string(&self, value: &str) {
632        unsafe {
633            ffi::json_node_set_string(self.to_glib_none().0, value.to_glib_none().0);
634        }
635    }
636
637    /// Sets a scalar value inside the given node.
638    ///
639    /// The contents of the given `GValue` are copied into the `JsonNode`.
640    ///
641    /// The following `GValue` types have a direct mapping to JSON types:
642    ///
643    ///  - `G_TYPE_INT64`
644    ///  - `G_TYPE_DOUBLE`
645    ///  - `G_TYPE_BOOLEAN`
646    ///  - `G_TYPE_STRING`
647    ///
648    /// JSON-GLib will also automatically promote the following `GValue` types:
649    ///
650    ///  - `G_TYPE_INT` to `G_TYPE_INT64`
651    ///  - `G_TYPE_FLOAT` to `G_TYPE_DOUBLE`
652    ///
653    /// It is an error to call this on an immutable node, or on a node which is not
654    /// a value node.
655    /// ## `value`
656    /// the value to set
657    #[doc(alias = "json_node_set_value")]
658    pub fn set_value(&self, value: &glib::Value) {
659        unsafe {
660            ffi::json_node_set_value(self.to_glib_none().0, value.to_glib_none().0);
661        }
662    }
663
664    /// Sets @array inside @self.
665    ///
666    /// The reference count of @array is not increased.
667    ///
668    /// It is a programmer error to call this on a node which doesn’t hold an
669    /// array value. Use `JSON_NODE_HOLDS_ARRAY` first.
670    /// ## `array`
671    /// a JSON array
672    #[doc(alias = "json_node_take_array")]
673    pub fn take_array(&self, array: Array) {
674        unsafe {
675            ffi::json_node_take_array(self.to_glib_none().0, array.into_glib_ptr());
676        }
677    }
678
679    /// Sets @object inside @self.
680    ///
681    /// The reference count of @object is not increased.
682    ///
683    /// It is an error to call this on an immutable node, or on a node which is not
684    /// an object node.
685    /// ## `object`
686    /// a JSON object
687    #[doc(alias = "json_node_take_object")]
688    pub fn take_object(&self, object: Object) {
689        unsafe {
690            ffi::json_node_take_object(self.to_glib_none().0, object.into_glib_ptr());
691        }
692    }
693
694    /// Retrieves the user readable name of the data type contained by @self.
695    ///
696    /// **Note**: The name is only meant for debugging purposes, and there is no
697    /// guarantee the name will stay the same across different versions.
698    ///
699    /// # Returns
700    ///
701    /// a string containing the name of the type
702    #[doc(alias = "json_node_type_name")]
703    pub fn type_name(&self) -> glib::GString {
704        unsafe {
705            from_glib_none(ffi::json_node_type_name(self.to_glib_none().0))
706        }
707    }
708}
709
710#[cfg(feature = "v1_2")]
711#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
712impl PartialEq for Node {
713    #[inline]
714    fn eq(&self, other: &Self) -> bool {
715        self.equal(other)
716    }
717}
718#[cfg(feature = "v1_2")]
719#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
720
721impl Eq for Node {}
722
723#[cfg(feature = "v1_2")]
724#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
725impl std::hash::Hash for Node {
726    #[inline]
727    fn hash<H>(&self, state: &mut H) where H: std::hash::Hasher {
728        std::hash::Hash::hash(&self.hash(), state)
729    }
730}