pub trait Transactable: ReadDoc {
    // Required methods
    fn pending_ops(&self) -> usize;
    fn put<O: AsRef<ExId>, P: Into<Prop>, V: Into<ScalarValue>>(
        &mut self,
        obj: O,
        prop: P,
        value: V
    ) -> Result<(), AutomergeError>;
    fn put_object<O: AsRef<ExId>, P: Into<Prop>>(
        &mut self,
        obj: O,
        prop: P,
        object: ObjType
    ) -> Result<ExId, AutomergeError>;
    fn insert<O: AsRef<ExId>, V: Into<ScalarValue>>(
        &mut self,
        obj: O,
        index: usize,
        value: V
    ) -> Result<(), AutomergeError>;
    fn insert_object<O: AsRef<ExId>>(
        &mut self,
        obj: O,
        index: usize,
        object: ObjType
    ) -> Result<ExId, AutomergeError>;
    fn increment<O: AsRef<ExId>, P: Into<Prop>>(
        &mut self,
        obj: O,
        prop: P,
        value: i64
    ) -> Result<(), AutomergeError>;
    fn delete<O: AsRef<ExId>, P: Into<Prop>>(
        &mut self,
        obj: O,
        prop: P
    ) -> Result<(), AutomergeError>;
    fn splice<O: AsRef<ExId>, V: IntoIterator<Item = ScalarValue>>(
        &mut self,
        obj: O,
        pos: usize,
        del: isize,
        vals: V
    ) -> Result<(), AutomergeError>;
    fn splice_text<O: AsRef<ExId>>(
        &mut self,
        obj: O,
        pos: usize,
        del: isize,
        text: &str
    ) -> Result<(), AutomergeError>;
    fn mark<O: AsRef<ExId>>(
        &mut self,
        obj: O,
        mark: Mark<'_>,
        expand: ExpandMark
    ) -> Result<(), AutomergeError>;
    fn unmark<O: AsRef<ExId>>(
        &mut self,
        obj: O,
        key: &str,
        start: usize,
        end: usize,
        expand: ExpandMark
    ) -> Result<(), AutomergeError>;
    fn base_heads(&self) -> Vec<ChangeHash>;
}
Expand description

A way of mutating a document within a single change.

Required Methods§

source

fn pending_ops(&self) -> usize

Get the number of pending operations in this transaction.

source

fn put<O: AsRef<ExId>, P: Into<Prop>, V: Into<ScalarValue>>( &mut self, obj: O, prop: P, value: V ) -> Result<(), AutomergeError>

Set the value of property P to value V in object obj.

Errors

This will return an error if

  • The object does not exist
  • The key is the wrong type for the object
  • The key does not exist in the object
source

fn put_object<O: AsRef<ExId>, P: Into<Prop>>( &mut self, obj: O, prop: P, object: ObjType ) -> Result<ExId, AutomergeError>

Set the value of property P to the new object V in object obj.

Returns

The id of the object which was created.

Errors

This will return an error if

  • The object does not exist
  • The key is the wrong type for the object
  • The key does not exist in the object
source

fn insert<O: AsRef<ExId>, V: Into<ScalarValue>>( &mut self, obj: O, index: usize, value: V ) -> Result<(), AutomergeError>

Insert a value into a list at the given index.

source

fn insert_object<O: AsRef<ExId>>( &mut self, obj: O, index: usize, object: ObjType ) -> Result<ExId, AutomergeError>

Insert an object into a list at the given index.

source

fn increment<O: AsRef<ExId>, P: Into<Prop>>( &mut self, obj: O, prop: P, value: i64 ) -> Result<(), AutomergeError>

Increment the counter at the prop in the object by value.

source

fn delete<O: AsRef<ExId>, P: Into<Prop>>( &mut self, obj: O, prop: P ) -> Result<(), AutomergeError>

Delete the value at prop in the object.

source

fn splice<O: AsRef<ExId>, V: IntoIterator<Item = ScalarValue>>( &mut self, obj: O, pos: usize, del: isize, vals: V ) -> Result<(), AutomergeError>

replace a section of a list. If del is positive then N values are deleted after position pos and the new values inserted. If it is negative then N values are deleted before position pos instead.

source

fn splice_text<O: AsRef<ExId>>( &mut self, obj: O, pos: usize, del: isize, text: &str ) -> Result<(), AutomergeError>

Like Self::splice but for text.

source

fn mark<O: AsRef<ExId>>( &mut self, obj: O, mark: Mark<'_>, expand: ExpandMark ) -> Result<(), AutomergeError>

Mark a sequence

source

fn unmark<O: AsRef<ExId>>( &mut self, obj: O, key: &str, start: usize, end: usize, expand: ExpandMark ) -> Result<(), AutomergeError>

Remove a Mark from a sequence

source

fn base_heads(&self) -> Vec<ChangeHash>

The heads this transaction will be based on

Implementors§