collab-common 0.0.7

Code shared by collab's client and server
Documentation
use cola::Anchor;
use serde::{Deserialize, Serialize};

use crate::PeerId;

/// TODO: docs
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Cursor {
    anchor: Anchor,
    owner: PeerId,
}

impl Cursor {
    /// Returns the [`Anchor`] the cursor placed is at.
    #[inline(always)]
    pub fn anchor(&self) -> Anchor {
        self.anchor
    }

    /// Returns the [`PeerId`] of the peer that owns the cursor.
    #[inline(always)]
    pub fn owner(&self) -> PeerId {
        self.owner
    }

    /// Creates a new `Cursor`.
    #[cfg(feature = "__client")]
    #[inline(always)]
    pub fn new(anchor: Anchor, owner: PeerId) -> Self {
        Self { anchor, owner }
    }
}