Struct loro_common::IdSpan

source ·
pub struct IdSpan {
    pub client_id: PeerID,
    pub counter: CounterSpan,
}
Expand description

This struct supports reverse repr: CounterSpan’s from can be less than to. But we should use it conservatively. We need this because it’ll make merging deletions easier.

Fields§

§client_id: PeerID§counter: CounterSpan

Implementations§

source§

impl IdSpan

source

pub fn new(client_id: PeerID, from: Counter, to: Counter) -> Self

source

pub fn contains(&self, id: ID) -> bool

source

pub fn is_reversed(&self) -> bool

source

pub fn reverse(&mut self)

source

pub fn normalize_(&mut self)

source

pub fn norm_id_start(&self) -> ID

This is different from id_start. id_start may be greater than id_end, but this is the min of id_start and id_end-1

source

pub fn norm_id_end(&self) -> ID

This is different from id_end. id_start may be greater than id_end. This is the max of id_start+1 and id_end

source

pub fn to_id_span_vec(self) -> IdSpanVector

Trait Implementations§

source§

impl Clone for IdSpan

source§

fn clone(&self) -> IdSpan

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for IdSpan

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<Slice<'a, IdSpan>> for IdSpan

source§

fn from(slice: Slice<'a, IdSpan>) -> Self

Converts to this type from the input type.
source§

impl HasId for IdSpan

source§

fn id_start(&self) -> ID

source§

impl HasLength for IdSpan

source§

fn content_len(&self) -> usize

It is the length of the content, i.e. the length when no Mergable::merge ever happen. Read more
source§

fn atom_len(&self) -> usize

It is the length of the atom element underneath, i.e. the length when no Mergable::merge ever happen. Read more
source§

impl Mergable for IdSpan

source§

fn is_mergable(&self, other: &Self, _: &()) -> bool

source§

fn merge(&mut self, other: &Self, _: &())

source§

impl PartialEq for IdSpan

source§

fn eq(&self, other: &IdSpan) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Sliceable for IdSpan

source§

fn slice(&self, from: usize, to: usize) -> Self

source§

impl Copy for IdSpan

source§

impl Eq for IdSpan

source§

impl StructuralEq for IdSpan

source§

impl StructuralPartialEq for IdSpan

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> HasCounter for Twhere T: HasId,

source§

fn ctr_start(&self) -> i32

source§

impl<T> HasCounterSpan for Twhere T: HasCounter + HasLength,

source§

fn ctr_end(&self) -> Counter

end is the exclusive end, last the inclusive end.
source§

fn ctr_last(&self) -> Counter

end is the exclusive end, last the inclusive end.
source§

fn ctr_span(&self) -> CounterSpan

source§

impl<T> HasIdSpan for Twhere T: HasId + HasLength,

source§

fn intersect<T: HasIdSpan>(&self, other: &T) -> bool

source§

fn id_span(&self) -> IdSpan

source§

fn id_end(&self) -> ID

end is the exclusive end, last the inclusive end.
source§

fn id_last(&self) -> ID

end is the exclusive end, last the inclusive end.
source§

fn contains_id(&self, id: ID) -> bool

source§

impl<T, U> Into<U> for Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T, Cfg> Rle<Cfg> for Twhere T: HasLength + Sliceable + Mergable<Cfg> + Debug + Clone,