Struct XmlElementRef
pub struct XmlElementRef(/* private fields */);Expand description
XML element data type. It represents an XML node, which can contain key-value attributes (interpreted as strings) as well as other nested XML elements or rich text (represented by XmlTextRef type).
In terms of conflict resolution, XmlElementRef uses following rules:
- Attribute updates use logical last-write-wins principle, meaning the past updates are automatically overridden and discarded by newer ones, while concurrent updates made by different peers are resolved into a single value using document id seniority to establish an order.
- Child node insertion uses sequencing rules from other Yrs collections - elements are inserted using interleave-resistant algorithm, where order of concurrent inserts at the same index is established using peer’s document id seniority.
Implementations§
Trait Implementations§
§impl AsPrelim for XmlElementRef
impl AsPrelim for XmlElementRef
§impl AsRef<ArrayRef> for XmlElementRef
impl AsRef<ArrayRef> for XmlElementRef
§impl AsRef<Branch> for XmlElementRef
impl AsRef<Branch> for XmlElementRef
§impl AsRef<XmlFragmentRef> for XmlElementRef
impl AsRef<XmlFragmentRef> for XmlElementRef
§fn as_ref(&self) -> &XmlFragmentRef
fn as_ref(&self) -> &XmlFragmentRef
Converts this type into a shared reference of the (usually inferred) input type.
§impl Clone for XmlElementRef
impl Clone for XmlElementRef
§fn clone(&self) -> XmlElementRef
fn clone(&self) -> XmlElementRef
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for XmlElementRef
impl Debug for XmlElementRef
§impl DeepObservable for XmlElementRef
impl DeepObservable for XmlElementRef
§fn observe_deep<F>(&self, f: F) -> Arc<dyn Drop>
fn observe_deep<F>(&self, f: F) -> Arc<dyn Drop>
§fn observe_deep_with<K, F>(&self, key: K, f: F)
fn observe_deep_with<K, F>(&self, key: K, f: F)
§fn unobserve_deep<K>(&self, key: K) -> bool
fn unobserve_deep<K>(&self, key: K) -> bool
Unsubscribe a callback identified by a given key, that was previously subscribed using
Self::observe_deep_with.
§impl From<BranchPtr> for XmlElementRef
impl From<BranchPtr> for XmlElementRef
§fn from(inner: BranchPtr) -> XmlElementRef
fn from(inner: BranchPtr) -> XmlElementRef
Converts to this type from the input type.
§impl GetString for XmlElementRef
impl GetString for XmlElementRef
§fn get_string<T>(&self, txn: &T) -> Stringwhere
T: ReadTxn,
fn get_string<T>(&self, txn: &T) -> Stringwhere
T: ReadTxn,
Converts current XML node into a textual representation. This representation if flat, it doesn’t include any indentation.
§impl IndexedSequence for XmlElementRef
impl IndexedSequence for XmlElementRef
§fn sticky_index<T>(
&self,
txn: &T,
index: u32,
assoc: Assoc,
) -> Option<StickyIndex>where
T: ReadTxn,
fn sticky_index<T>(
&self,
txn: &T,
index: u32,
assoc: Assoc,
) -> Option<StickyIndex>where
T: ReadTxn,
Returns a StickyIndex equivalent to a human-readable
index.
Returns None if index is beyond the length of current sequence.§impl Observable for XmlElementRef
impl Observable for XmlElementRef
type Event = XmlEvent
§fn observe<F>(&self, f: F) -> Arc<dyn Drop>
fn observe<F>(&self, f: F) -> Arc<dyn Drop>
Subscribes a given callback to be triggered whenever current y-type is changed.
A callback is triggered whenever a transaction gets committed. This function does not
trigger if changes have been observed by nested shared collections. Read more
§fn observe_with<K, F>(&self, key: K, f: F)
fn observe_with<K, F>(&self, key: K, f: F)
Subscribes a given callback to be triggered whenever current y-type is changed.
A callback is triggered whenever a transaction gets committed. This function does not
trigger if changes have been observed by nested shared collections. Read more
§impl PartialEq for XmlElementRef
impl PartialEq for XmlElementRef
§impl TryFrom<ItemPtr> for XmlElementRef
impl TryFrom<ItemPtr> for XmlElementRef
§impl TryFrom<Out> for XmlElementRef
impl TryFrom<Out> for XmlElementRef
§impl TryInto<XmlElementRef> for XmlOut
impl TryInto<XmlElementRef> for XmlOut
§impl Xml for XmlElementRef
impl Xml for XmlElementRef
fn parent(&self) -> Option<XmlOut>
§fn remove_attribute<K>(&self, txn: &mut TransactionMut<'_>, attr_name: &K)
fn remove_attribute<K>(&self, txn: &mut TransactionMut<'_>, attr_name: &K)
Removes an attribute recognized by an
attr_name from a current XML element.§fn insert_attribute<K, V>(
&self,
txn: &mut TransactionMut<'_>,
key: K,
value: V,
) -> <V as Prelim>::Return
fn insert_attribute<K, V>( &self, txn: &mut TransactionMut<'_>, key: K, value: V, ) -> <V as Prelim>::Return
Inserts an attribute entry into current XML element.
§fn get_attribute<T>(&self, txn: &T, attr_name: &str) -> Option<Out>where
T: ReadTxn,
fn get_attribute<T>(&self, txn: &T, attr_name: &str) -> Option<Out>where
T: ReadTxn,
Returns a value of an attribute given its
attr_name. Returns None if no such attribute
can be found inside of a current XML element.§fn attributes<'a, T>(&'a self, txn: &'a T) -> Attributes<'a, &'a T, T> ⓘwhere
T: ReadTxn,
fn attributes<'a, T>(&'a self, txn: &'a T) -> Attributes<'a, &'a T, T> ⓘwhere
T: ReadTxn,
Returns an unordered iterator over all attributes (key-value pairs), that can be found
inside of a current XML element.
fn siblings<'a, T>(&self, txn: &'a T) -> Siblings<'a, T> ⓘwhere
T: ReadTxn,
§impl XmlFragment for XmlElementRef
impl XmlFragment for XmlElementRef
fn first_child(&self) -> Option<XmlOut>
§fn children<'a, T>(&self, txn: &'a T) -> XmlNodes<'a, T> ⓘwhere
T: ReadTxn,
fn children<'a, T>(&self, txn: &'a T) -> XmlNodes<'a, T> ⓘwhere
T: ReadTxn,
Returns an iterator over all children of a current XML fragment.
It does NOT include nested children of its children - for such cases use Self::successors
iterator.
§fn len<T>(&self, _txn: &T) -> u32where
T: ReadTxn,
fn len<T>(&self, _txn: &T) -> u32where
T: ReadTxn,
Returns a number of elements stored in current array.
§fn insert<V>(
&self,
txn: &mut TransactionMut<'_>,
index: u32,
xml_node: V,
) -> <V as Prelim>::Returnwhere
V: XmlPrelim,
fn insert<V>(
&self,
txn: &mut TransactionMut<'_>,
index: u32,
xml_node: V,
) -> <V as Prelim>::Returnwhere
V: XmlPrelim,
Inserts a
value at the given index. Inserting at index 0 is equivalent to prepending
current array with given value, while inserting at array length is equivalent to appending
that value at the end of it. Read more§fn push_back<V>(
&self,
txn: &mut TransactionMut<'_>,
xml_node: V,
) -> <V as Prelim>::Returnwhere
V: XmlPrelim,
fn push_back<V>(
&self,
txn: &mut TransactionMut<'_>,
xml_node: V,
) -> <V as Prelim>::Returnwhere
V: XmlPrelim,
Inserts given
value at the end of the current array.§fn push_front<V>(
&self,
txn: &mut TransactionMut<'_>,
xml_node: V,
) -> <V as Prelim>::Returnwhere
V: XmlPrelim,
fn push_front<V>(
&self,
txn: &mut TransactionMut<'_>,
xml_node: V,
) -> <V as Prelim>::Returnwhere
V: XmlPrelim,
Inserts given
value at the beginning of the current array.§fn remove(&self, txn: &mut TransactionMut<'_>, index: u32)
fn remove(&self, txn: &mut TransactionMut<'_>, index: u32)
Removes a single element at provided
index.§fn remove_range(&self, txn: &mut TransactionMut<'_>, index: u32, len: u32)
fn remove_range(&self, txn: &mut TransactionMut<'_>, index: u32, len: u32)
Removes a range of elements from current array, starting at given
index up until
a particular number described by len has been deleted. This method panics in case when
not all expected elements were removed (due to insufficient number of elements in an array)
or index is outside the bounds of an array.§fn get<T>(&self, _txn: &T, index: u32) -> Option<XmlOut>where
T: ReadTxn,
fn get<T>(&self, _txn: &T, index: u32) -> Option<XmlOut>where
T: ReadTxn,
Retrieves a value stored at a given
index. Returns None when provided index was out
of the range of a current array.§fn successors<'a, T>(&'a self, txn: &'a T) -> TreeWalker<'a, &'a T, T> ⓘwhere
T: ReadTxn,
fn successors<'a, T>(&'a self, txn: &'a T) -> TreeWalker<'a, &'a T, T> ⓘwhere
T: ReadTxn,
Returns an iterator that can be used to traverse over the successors of a current
XML element. This includes recursive step over children of its children. The recursive
iteration is depth-first. Read more
impl Eq for XmlElementRef
Auto Trait Implementations§
impl Freeze for XmlElementRef
impl !RefUnwindSafe for XmlElementRef
impl Send for XmlElementRef
impl Sync for XmlElementRef
impl Unpin for XmlElementRef
impl !UnwindSafe for XmlElementRef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more