pub struct Annotation {
pub start_byte: usize,
pub end_byte: usize,
pub category: HighlightCategory,
}Expand description
A single annotation on a buffer range.
Annotations are the unified representation for all semantic markup: syntax highlights, decorations, diagnostics, search matches, etc.
The server emits only byte ranges and categories (mechanism). Clients decide how to render each category (policy).
§Example
use reovim_driver_syntax::{Annotation, HighlightCategory};
let ann = Annotation::new(0, 5, HighlightCategory::new("keyword.function"));
assert_eq!(ann.category.as_str(), "keyword.function");
assert_eq!(ann.len(), 5);Fields§
§start_byte: usizeStart byte offset (inclusive).
end_byte: usizeEnd byte offset (exclusive).
category: HighlightCategoryCategory string (e.g., “keyword.function”, “markup.heading.1”).
Implementations§
Source§impl Annotation
impl Annotation
Sourcepub const fn new(
start_byte: usize,
end_byte: usize,
category: HighlightCategory,
) -> Self
pub const fn new( start_byte: usize, end_byte: usize, category: HighlightCategory, ) -> Self
Create an annotation.
Sourcepub const fn overlaps(&self, range: &Range<usize>) -> bool
pub const fn overlaps(&self, range: &Range<usize>) -> bool
Check if this annotation overlaps with a byte range.
Sourcepub const fn contains(&self, byte: usize) -> bool
pub const fn contains(&self, byte: usize) -> bool
Check if this annotation contains a byte offset.
Sourcepub const fn byte_range(&self) -> Range<usize>
pub const fn byte_range(&self) -> Range<usize>
Get this annotation as a byte range.
Trait Implementations§
Source§impl Clone for Annotation
impl Clone for Annotation
Source§fn clone(&self) -> Annotation
fn clone(&self) -> Annotation
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 Annotation
impl Debug for Annotation
Source§impl PartialEq for Annotation
impl PartialEq for Annotation
impl Eq for Annotation
impl StructuralPartialEq for Annotation
Auto Trait Implementations§
impl Freeze for Annotation
impl RefUnwindSafe for Annotation
impl Send for Annotation
impl Sync for Annotation
impl Unpin for Annotation
impl UnsafeUnpin for Annotation
impl UnwindSafe for Annotation
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