Skip to main content

DocumentComments

Struct DocumentComments 

Source
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

Source

pub fn new() -> DocumentComments

Source

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.

Source

pub fn get(&self, uid: &str) -> Option<&DocumentComment>

Source

pub fn iter(&self) -> impl Iterator<Item = &DocumentComment>

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

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

Source§

fn clone(&self) -> DocumentComments

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
Source§

impl Debug for DocumentComments

Source§

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

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

impl Default for DocumentComments

Source§

fn default() -> DocumentComments

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for DocumentComments

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<DocumentComments, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for DocumentComments

Source§

impl FromIterator<DocumentComment> for DocumentComments

Source§

fn from_iter<I>(iter: I) -> DocumentComments
where I: IntoIterator<Item = DocumentComment>,

Creates a value from an iterator. Read more
Source§

impl PartialEq for DocumentComments

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for DocumentComments

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DocumentComments

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
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, !>

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.