Skip to main content

Replica

Struct Replica 

Source
pub struct Replica { /* private fields */ }

Implementations§

Source§

impl Replica

Source

pub fn new(id: NonZeroU32, initial_length: usize) -> Self

The id must be unique among replicas of the same document. The initial content is credited to this replica’s clock, so replicas joining an existing session must fork one that’s already in it rather than call new themselves.

Source

pub fn fork(&self, new_id: NonZeroU32) -> Self

A copy of this replica that authors its own edits under a new id.

Source

pub fn len(&self) -> usize

The visible length of the document, in bytes.

Source

pub fn is_empty(&self) -> bool

Source

pub fn inserted( &mut self, byte_offset: usize, length: usize, ) -> Result<Insertion>

Informs the replica that length bytes were inserted at the given visible offset in the caller’s buffer, returning the op to send to the other replicas.

Source

pub fn deleted(&mut self, byte_range: Range<usize>) -> Result<Deletion>

Informs the replica that the given visible byte range was deleted from the caller’s buffer, returning the op to send to the other replicas. Note [Deletion by id]

Source

pub fn integrate_insertion(&mut self, op: &Insertion) -> Vec<BufferEdit>

Integrates another replica’s Insertion, returning the edits to apply to the caller’s buffer, in order: the op itself and any pending ops it unblocked. Empty when the op is a duplicate, empty, or must wait for its causal dependencies. Note [Pending ops]

Source

pub fn integrate_deletion(&mut self, op: &Deletion) -> Vec<BufferEdit>

Integrates another replica’s Deletion, returning the edits to apply to the caller’s buffer. Empty when nothing new was deleted or the op must wait for its causal dependencies. Note [Deletion by id]

Trait Implementations§

Source§

impl Clone for Replica

Source§

fn clone(&self) -> Replica

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.