pub struct DocumentComments(/* private fields */);Expand description
Every comment thread supplied to one export, keyed by DocumentComment::uid.
A BTreeMap, not a HashMap, for the same reason super::image_options::ExportImages
is one: two exports of the same document must be byte-comparable, and a randomised
iteration order would quietly break that. Keying by uid rather than storing a bare Vec
also makes “does this document already carry a thread with this id” an O(log n) lookup
instead of a linear scan — relevant because a caller re-exporting after an edit typically
hands over its whole current comment set again, not just what changed since last time.
Iteration order is uid order, which is not the order a writer needs to open and close
ranges in as it walks the document front to back — use
in_document_order for that.
Implementations§
Source§impl DocumentComments
impl DocumentComments
pub fn new() -> DocumentComments
Sourcepub fn insert(&mut self, comment: DocumentComment) -> &mut DocumentComments
pub fn insert(&mut self, comment: DocumentComment) -> &mut DocumentComments
Register a comment, keyed by its own uid. A second insert under the same uid
replaces the first — the caller is expected to hand over its current state on every
export, not maintain an append-only log through this type.
pub fn get(&self, uid: &str) -> Option<&DocumentComment>
pub fn iter(&self) -> impl Iterator<Item = &DocumentComment>
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Sourcepub fn in_document_order(&self) -> Vec<&DocumentComment>
pub fn in_document_order(&self) -> Vec<&DocumentComment>
Every comment, sorted by (start, end, uid) — the order a writer walking the document
text front-to-back needs to open and close ranges in. uid breaks an exact
(start, end) tie deterministically (two threads anchored to the identical span)
rather than leaving it to whatever order the BTreeMap’s own key (uid again, but
unsorted by position) happened to produce.
Trait Implementations§
Source§impl Clone for DocumentComments
impl Clone for DocumentComments
Source§fn clone(&self) -> DocumentComments
fn clone(&self) -> DocumentComments
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DocumentComments
impl Debug for DocumentComments
Source§impl Default for DocumentComments
impl Default for DocumentComments
Source§fn default() -> DocumentComments
fn default() -> DocumentComments
Source§impl<'de> Deserialize<'de> for DocumentComments
impl<'de> Deserialize<'de> for DocumentComments
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DocumentComments, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DocumentComments, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for DocumentComments
Source§impl FromIterator<DocumentComment> for DocumentComments
impl FromIterator<DocumentComment> for DocumentComments
Source§fn from_iter<I>(iter: I) -> DocumentCommentswhere
I: IntoIterator<Item = DocumentComment>,
fn from_iter<I>(iter: I) -> DocumentCommentswhere
I: IntoIterator<Item = DocumentComment>,
Source§impl PartialEq for DocumentComments
impl PartialEq for DocumentComments
Source§impl Serialize for DocumentComments
impl Serialize for DocumentComments
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for DocumentComments
Auto Trait Implementations§
impl Freeze for DocumentComments
impl RefUnwindSafe for DocumentComments
impl Send for DocumentComments
impl Sync for DocumentComments
impl Unpin for DocumentComments
impl UnsafeUnpin for DocumentComments
impl UnwindSafe for DocumentComments
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.