Trait yrs::block::Prelim

source ·
pub trait Prelim: Sized {
    type Return: TryFrom<ItemPtr>;

    // Required methods
    fn into_content(
        self,
        txn: &mut TransactionMut<'_>
    ) -> (ItemContent, Option<Self>);
    fn integrate(self, txn: &mut TransactionMut<'_>, inner_ref: BranchPtr);
}
Expand description

A trait used for preliminary types, that can be inserted into shared Yrs collections.

Required Associated Types§

source

type Return: TryFrom<ItemPtr>

Type of a value to be returned as a result of inserting this Prelim type instance. Use Unused if none is necessary.

Required Methods§

source

fn into_content( self, txn: &mut TransactionMut<'_> ) -> (ItemContent, Option<Self>)

This method is used to create initial content required in order to create a block item. A supplied ptr can be used to identify block that is about to be created to store the returned content.

Since this method may decide to consume self or not, a second optional return parameter is used when self was not consumed - which is the case for complex types creation such as YMap or YArray. In such case it will be passed later on to Self::integrate method.

source

fn integrate(self, txn: &mut TransactionMut<'_>, inner_ref: BranchPtr)

Method called once an original item filled with content from Self::into_content has been added to block store. This method is used by complex types such as maps or arrays to append the original contents of prelim struct into YMap, YArray etc.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Prelim for Doc

§

type Return = Doc

source§

impl<I, T> Prelim for XmlElementPrelim<I, T>
where I: IntoIterator<Item = T>, T: XmlPrelim,

source§

impl<I, T> Prelim for XmlFragmentPrelim<I, T>
where I: IntoIterator<Item = T>, T: XmlPrelim, <T as Prelim>::Return: TryFrom<ItemPtr>,

source§

impl<T> Prelim for EmbedPrelim<T>
where T: Prelim,

§

type Return = <T as Prelim>::Return

source§

impl<T> Prelim for T
where T: Into<Any>,

source§

impl<T, V> Prelim for ArrayPrelim<T, V>
where V: Prelim, T: IntoIterator<Item = V>,

source§

impl<T: Borrow<str>> Prelim for TextPrelim<T>

source§

impl<T: Borrow<str>> Prelim for XmlTextPrelim<T>

source§

impl<T: Prelim> Prelim for MapPrelim<T>