pub struct ContentAnchor {
pub block_id: String,
pub offset: Option<usize>,
pub start: Option<usize>,
pub end: Option<usize>,
pub content_hash: Option<DocumentId>,
}Expand description
A content anchor referencing a location within the document.
Anchors can reference:
- An entire block (block-level anchor)
- A specific character position within a block (point anchor)
- A character range within a block (range anchor)
Fields§
§block_id: StringThe ID of the referenced block.
offset: Option<usize>Character offset for point anchors.
When present without end, this is a point anchor.
start: Option<usize>Start of range for range anchors.
end: Option<usize>End of range for range anchors (exclusive).
content_hash: Option<DocumentId>Optional content hash for stale detection. When set, can be used to detect if the referenced content has changed.
Implementations§
Source§impl ContentAnchor
impl ContentAnchor
Sourcepub fn block(block_id: impl Into<String>) -> Self
pub fn block(block_id: impl Into<String>) -> Self
Create a block-level anchor referencing an entire block.
Sourcepub fn point(block_id: impl Into<String>, offset: usize) -> Self
pub fn point(block_id: impl Into<String>, offset: usize) -> Self
Create a point anchor at a specific character offset.
Sourcepub fn range(block_id: impl Into<String>, start: usize, end: usize) -> Self
pub fn range(block_id: impl Into<String>, start: usize, end: usize) -> Self
Create a range anchor spanning a character range.
Sourcepub fn with_content_hash(self, hash: DocumentId) -> Self
pub fn with_content_hash(self, hash: DocumentId) -> Self
Set the content hash for stale detection.
Sourcepub fn is_block_anchor(&self) -> bool
pub fn is_block_anchor(&self) -> bool
Check if this is a block-level anchor (no point or range).
Sourcepub fn is_point_anchor(&self) -> bool
pub fn is_point_anchor(&self) -> bool
Check if this is a point anchor.
Sourcepub fn is_range_anchor(&self) -> bool
pub fn is_range_anchor(&self) -> bool
Check if this is a range anchor.
Sourcepub fn to_uri(&self) -> ContentAnchorUri
pub fn to_uri(&self) -> ContentAnchorUri
Convert to URI format.
Trait Implementations§
Source§impl Clone for ContentAnchor
impl Clone for ContentAnchor
Source§fn clone(&self) -> ContentAnchor
fn clone(&self) -> ContentAnchor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContentAnchor
impl Debug for ContentAnchor
Source§impl<'de> Deserialize<'de> for ContentAnchor
impl<'de> Deserialize<'de> for ContentAnchor
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<ContentAnchor> for ContentAnchorUri
impl From<ContentAnchor> for ContentAnchorUri
Source§fn from(anchor: ContentAnchor) -> Self
fn from(anchor: ContentAnchor) -> Self
Converts to this type from the input type.
Source§impl From<ContentAnchorUri> for ContentAnchor
impl From<ContentAnchorUri> for ContentAnchor
Source§fn from(uri: ContentAnchorUri) -> Self
fn from(uri: ContentAnchorUri) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ContentAnchor
impl PartialEq for ContentAnchor
Source§impl Serialize for ContentAnchor
impl Serialize for ContentAnchor
impl Eq for ContentAnchor
impl StructuralPartialEq for ContentAnchor
Auto Trait Implementations§
impl Freeze for ContentAnchor
impl RefUnwindSafe for ContentAnchor
impl Send for ContentAnchor
impl Sync for ContentAnchor
impl Unpin for ContentAnchor
impl UnsafeUnpin for ContentAnchor
impl UnwindSafe for ContentAnchor
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
key and return true if they are equal.