pub struct DocumentMark {
pub start: u32,
pub end: u32,
pub name: String,
pub ordinal: u32,
}Expand description
One named position or range in the document’s addressable character space.
Fields§
§start: u32[start, end) in the document’s addressable character space — the same space
DocumentComment::start uses, and the
same one TextDocument::to_addressable_text() reports. start == end is a point mark.
end: u32§name: StringThe bookmark name, which is the whole message. See validate.
ordinal: u32Which of several marks sharing this exact range comes first.
Zero for every mark that does not share its range with another, which is almost all of them, so it can be ignored by any caller that never emits two.
It exists because ties have to break the same way on both payloads. A comment and
the mark carrying its identity are two objects the writers sort independently:
DocumentComments breaks a tie on the
comment’s uid, and this on the mark’s name. Where a name is derived from a uid by
hashing — which is what a 40-character bookmark limit forces — the two orders are
uncorrelated, so a document with two comments on the identical range can emit the
annotations in one order and their marks in the other. A reader matching them by
position then hands each comment the other’s identity, and the editor’s remark comes
home on the wrong thread.
The producer knows the intended order and nothing else can recover it, so the producer says: set this from the same sequence the comments are built in.
#[serde(default)] because this field was added after the type shipped: a payload
serialized before it exists has no ordinal, and reading it back must give 0 rather
than fail. The default is also the correct answer for such a payload — it was written
by a producer that stated no order.
Implementations§
Source§impl DocumentMark
impl DocumentMark
Sourcepub fn range(start: u32, end: u32, name: impl Into<String>) -> DocumentMark
pub fn range(start: u32, end: u32, name: impl Into<String>) -> DocumentMark
A range mark over [start, end).
Sourcepub fn with_ordinal(self, ordinal: u32) -> DocumentMark
pub fn with_ordinal(self, ordinal: u32) -> DocumentMark
This mark, ordered ahead of or behind others sharing its exact range.
See ordinal — required only when two marks can span the same
characters, which for a host carrying comment identity means two comments on one
paragraph.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Check the name against the stricter of the two formats’ rules, and the range against itself.
Returns a description of the problem rather than a bool, because every caller of this wants to say what was wrong: these names are minted by the host from its own data, so a rejected one is a programming error and deserves to be reported as one — not silently dropped, which would leave an export that looks complete and cannot be read back.
Trait Implementations§
Source§impl Clone for DocumentMark
impl Clone for DocumentMark
Source§fn clone(&self) -> DocumentMark
fn clone(&self) -> DocumentMark
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 DocumentMark
impl Debug for DocumentMark
Source§impl Default for DocumentMark
impl Default for DocumentMark
Source§fn default() -> DocumentMark
fn default() -> DocumentMark
Source§impl<'de> Deserialize<'de> for DocumentMark
impl<'de> Deserialize<'de> for DocumentMark
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DocumentMark, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DocumentMark, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for DocumentMark
Source§impl PartialEq for DocumentMark
impl PartialEq for DocumentMark
Source§impl Serialize for DocumentMark
impl Serialize for DocumentMark
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 DocumentMark
Auto Trait Implementations§
impl Freeze for DocumentMark
impl RefUnwindSafe for DocumentMark
impl Send for DocumentMark
impl Sync for DocumentMark
impl Unpin for DocumentMark
impl UnsafeUnpin for DocumentMark
impl UnwindSafe for DocumentMark
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.