Struct yrs::types::xml::XmlElementRef
source · 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§
source§impl AsMut<Branch> for XmlElementRef
impl AsMut<Branch> for XmlElementRef
source§impl AsRef<Branch> for XmlElementRef
impl AsRef<Branch> for XmlElementRef
source§impl Clone for XmlElementRef
impl Clone for XmlElementRef
source§fn clone(&self) -> XmlElementRef
fn clone(&self) -> XmlElementRef
Returns a copy 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 moresource§impl Debug for XmlElementRef
impl Debug for XmlElementRef
source§impl From<BranchPtr> for XmlElementRef
impl From<BranchPtr> for XmlElementRef
source§impl GetString for XmlElementRef
impl GetString for XmlElementRef
source§impl IndexedSequence for XmlElementRef
impl IndexedSequence for XmlElementRef
source§fn sticky_index(
&self,
txn: &mut TransactionMut<'_>,
index: u32,
assoc: Assoc
) -> Option<StickyIndex>
fn sticky_index( &self, txn: &mut TransactionMut<'_>, index: u32, assoc: Assoc ) -> Option<StickyIndex>
Returns a StickyIndex equivalent to a human-readable
index.
Returns None if index is beyond the length of current sequence.source§impl Into<ArrayRef> for XmlElementRef
impl Into<ArrayRef> for XmlElementRef
source§impl Into<MapRef> for XmlElementRef
impl Into<MapRef> for XmlElementRef
source§impl Into<XmlFragmentRef> for XmlElementRef
impl Into<XmlFragmentRef> for XmlElementRef
source§fn into(self) -> XmlFragmentRef
fn into(self) -> XmlFragmentRef
Converts this type into the (usually inferred) input type.
source§impl Observable for XmlElementRef
impl Observable for XmlElementRef
type Event = XmlEvent
fn try_observer( &self ) -> Option<&Observer<Arc<dyn Fn(&TransactionMut<'_>, &Self::Event)>>>
fn try_observer_mut( &mut self ) -> Option<&mut Observer<Arc<dyn Fn(&TransactionMut<'_>, &Self::Event)>>>
source§fn observe<F>(
&mut self,
f: F
) -> Subscription<Arc<dyn Fn(&TransactionMut<'_>, &Self::Event)>>where
F: Fn(&TransactionMut<'_>, &Self::Event) + 'static,
fn observe<F>( &mut self, f: F ) -> Subscription<Arc<dyn Fn(&TransactionMut<'_>, &Self::Event)>>where F: Fn(&TransactionMut<'_>, &Self::Event) + 'static,
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
source§fn unobserve(&self, subscription_id: SubscriptionId)
fn unobserve(&self, subscription_id: SubscriptionId)
Unsubscribes a previously subscribed event callback identified by given
subscription_id.source§impl PartialEq for XmlElementRef
impl PartialEq for XmlElementRef
source§fn eq(&self, other: &XmlElementRef) -> bool
fn eq(&self, other: &XmlElementRef) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl TryFrom<BlockPtr> for XmlElementRef
impl TryFrom<BlockPtr> for XmlElementRef
source§impl TryFrom<Value> for XmlElementRef
impl TryFrom<Value> for XmlElementRef
source§impl TryInto<XmlElementRef> for XmlNode
impl TryInto<XmlElementRef> for XmlNode
source§impl Xml for XmlElementRef
impl Xml for XmlElementRef
fn parent(&self) -> Option<XmlNode>
source§fn remove_attribute<K>(&self, txn: &mut TransactionMut<'_>, attr_name: &K)where
K: AsRef<str>,
fn remove_attribute<K>(&self, txn: &mut TransactionMut<'_>, attr_name: &K)where K: AsRef<str>,
Removes an attribute recognized by an
attr_name from a current XML element.source§fn insert_attribute<K, V>(
&self,
txn: &mut TransactionMut<'_>,
attr_name: K,
attr_value: V
)where
K: Into<Arc<str>>,
V: Into<String>,
fn insert_attribute<K, V>( &self, txn: &mut TransactionMut<'_>, attr_name: K, attr_value: V )where K: Into<Arc<str>>, V: Into<String>,
Inserts an attribute entry into current XML element.
source§fn get_attribute<T: ReadTxn>(&self, txn: &T, attr_name: &str) -> Option<String>
fn get_attribute<T: ReadTxn>(&self, txn: &T, attr_name: &str) -> Option<String>
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.source§fn attributes<'a, T: ReadTxn>(&'a self, txn: &'a T) -> Attributes<'a, &'a T, T> ⓘ
fn attributes<'a, T: ReadTxn>(&'a self, txn: &'a T) -> Attributes<'a, &'a T, T> ⓘ
Returns an unordered iterator over all attributes (key-value pairs), that can be found
inside of a current XML element.
fn siblings<'a, T: ReadTxn>(&self, txn: &'a T) -> Siblings<'a, T> ⓘ
source§impl XmlFragment for XmlElementRef
impl XmlFragment for XmlElementRef
fn first_child(&self) -> Option<XmlNode>
source§fn len<T: ReadTxn>(&self, txn: &T) -> u32
fn len<T: ReadTxn>(&self, txn: &T) -> u32
Returns a number of elements stored in current array.
source§fn insert<V>(
&self,
txn: &mut TransactionMut<'_>,
index: u32,
xml_node: V
) -> V::Returnwhere
V: XmlPrelim,
fn insert<V>( &self, txn: &mut TransactionMut<'_>, index: u32, xml_node: V ) -> V::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 moresource§fn push_back<V>(&self, txn: &mut TransactionMut<'_>, xml_node: V) -> V::Returnwhere
V: XmlPrelim,
fn push_back<V>(&self, txn: &mut TransactionMut<'_>, xml_node: V) -> V::Returnwhere V: XmlPrelim,
Inserts given
value at the end of the current array.source§fn push_front<V>(&self, txn: &mut TransactionMut<'_>, xml_node: V) -> V::Returnwhere
V: XmlPrelim,
fn push_front<V>(&self, txn: &mut TransactionMut<'_>, xml_node: V) -> V::Returnwhere V: XmlPrelim,
Inserts given
value at the beginning of the current array.source§fn remove(&self, txn: &mut TransactionMut<'_>, index: u32)
fn remove(&self, txn: &mut TransactionMut<'_>, index: u32)
Removes a single element at provided
index.source§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 of the bounds of an array.source§fn get<T: ReadTxn>(&self, txn: &T, index: u32) -> Option<XmlNode>
fn get<T: ReadTxn>(&self, txn: &T, index: u32) -> Option<XmlNode>
Retrieves a value stored at a given
index. Returns None when provided index was out
of the range of a current array.source§fn successors<'a, T: ReadTxn>(&'a self, txn: &'a T) -> TreeWalker<'a, &'a T, T> ⓘ
fn successors<'a, T: ReadTxn>(&'a self, txn: &'a T) -> TreeWalker<'a, &'a T, T> ⓘ
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
impl StructuralEq for XmlElementRef
impl StructuralPartialEq for XmlElementRef
Auto Trait Implementations§
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> DeepObservable for Twhere
T: AsMut<Branch>,
impl<T> DeepObservable for Twhere T: AsMut<Branch>,
source§fn observe_deep<F>(
&mut self,
f: F
) -> Subscription<Arc<dyn Fn(&TransactionMut<'_>, &Events)>>where
F: Fn(&TransactionMut<'_>, &Events) + 'static,
fn observe_deep<F>( &mut self, f: F ) -> Subscription<Arc<dyn Fn(&TransactionMut<'_>, &Events)>>where F: Fn(&TransactionMut<'_>, &Events) + 'static,
source§fn unobserve_deep(&mut self, subscription_id: u32)
fn unobserve_deep(&mut self, subscription_id: u32)
Unobserves callback identified by
subscription_id (which can be obtained by consuming
Subscription using into cast).source§impl<T> Transact for Twhere
T: AsRef<Branch>,
impl<T> Transact for Twhere T: AsRef<Branch>,
source§fn try_transact(&self) -> Result<Transaction<'_>, TransactionAcqError>
fn try_transact(&self) -> Result<Transaction<'_>, TransactionAcqError>
Creates and returns a lightweight read-only transaction. Read more
source§fn try_transact_mut(&self) -> Result<TransactionMut<'_>, TransactionAcqError>
fn try_transact_mut(&self) -> Result<TransactionMut<'_>, TransactionAcqError>
Creates and returns a read-write capable transaction. This transaction can be used to
mutate the contents of underlying document store and upon dropping or committing it may
subscription callbacks. Read more
source§fn try_transact_mut_with<O>(
&self,
origin: O
) -> Result<TransactionMut<'_>, TransactionAcqError>where
O: Into<Origin>,
fn try_transact_mut_with<O>( &self, origin: O ) -> Result<TransactionMut<'_>, TransactionAcqError>where O: Into<Origin>,
Creates and returns a read-write capable transaction with an
origin classifier attached.
This transaction can be used to mutate the contents of underlying document store and upon
dropping or committing it may subscription callbacks. Read moresource§fn transact_mut_with<T>(&self, origin: T) -> TransactionMut<'_>where
T: Into<Origin>,
fn transact_mut_with<T>(&self, origin: T) -> TransactionMut<'_>where T: Into<Origin>,
Creates and returns a read-write capable transaction with an
origin classifier attached.
This transaction can be used to mutate the contents of underlying document store and upon
dropping or committing it may subscription callbacks. Read moresource§fn transact(&self) -> Transaction<'_>
fn transact(&self) -> Transaction<'_>
Creates and returns a lightweight read-only transaction. Read more
source§fn transact_mut(&self) -> TransactionMut<'_>
fn transact_mut(&self) -> TransactionMut<'_>
Creates and returns a read-write capable transaction. This transaction can be used to
mutate the contents of underlying document store and upon dropping or committing it may
subscription callbacks. Read more