pub struct AnnotatedOutput {
pub visual: String,
pub annotations: Vec<WidgetAnnotation>,
}Expand description
Combined visual and semantic output from a rendered frame.
This pairs the visual text representation (what a human would see) with structured annotation data (what a machine can parse).
§Example
use envision::annotation::{AnnotatedOutput, AnnotationRegistry, Annotation, with_annotations};
use envision::backend::CaptureBackend;
use ratatui::Terminal;
let backend = CaptureBackend::new(80, 24);
let mut terminal = Terminal::new(backend).unwrap();
let registry = with_annotations(|| {
terminal.draw(|frame| {
// Render widgets with annotations...
}).unwrap();
});
let output = AnnotatedOutput::from_backend_and_registry(terminal.backend(), ®istry);
assert!(!output.visual.is_empty());Fields§
§visual: StringThe visual text representation of the rendered frame.
annotations: Vec<WidgetAnnotation>Structured annotations for each widget in the frame.
Implementations§
Source§impl AnnotatedOutput
impl AnnotatedOutput
Sourcepub fn from_backend_and_registry(
backend: &CaptureBackend,
registry: &AnnotationRegistry,
) -> Self
pub fn from_backend_and_registry( backend: &CaptureBackend, registry: &AnnotationRegistry, ) -> Self
Creates an AnnotatedOutput from a CaptureBackend and an AnnotationRegistry.
The visual output is the plain text representation of the backend’s
current buffer. The annotations are converted from the registry’s
region data into a flat list of WidgetAnnotation values.
Sourcepub fn from_visual_and_registry(
visual: String,
registry: &AnnotationRegistry,
) -> Self
pub fn from_visual_and_registry( visual: String, registry: &AnnotationRegistry, ) -> Self
Creates an AnnotatedOutput from a visual string and an AnnotationRegistry.
This is useful when you already have the visual output as a string and want to pair it with annotation data.
Sourcepub fn annotation_count(&self) -> usize
pub fn annotation_count(&self) -> usize
Returns the number of annotations.
Sourcepub fn find_by_type(&self, widget_type: &str) -> Vec<&WidgetAnnotation>
pub fn find_by_type(&self, widget_type: &str) -> Vec<&WidgetAnnotation>
Finds annotations by widget type name.
Sourcepub fn find_by_id(&self, id: &str) -> Option<&WidgetAnnotation>
pub fn find_by_id(&self, id: &str) -> Option<&WidgetAnnotation>
Finds an annotation by its id.
Sourcepub fn focused_annotations(&self) -> Vec<&WidgetAnnotation>
pub fn focused_annotations(&self) -> Vec<&WidgetAnnotation>
Returns all focused annotations.
Sourcepub fn to_json(&self) -> Option<String>
pub fn to_json(&self) -> Option<String>
Serializes the output to a JSON string.
Returns None if serialization fails.
Sourcepub fn to_json_pretty(&self) -> Option<String>
pub fn to_json_pretty(&self) -> Option<String>
Serializes the output to a pretty-printed JSON string.
Returns None if serialization fails.
Trait Implementations§
Source§impl Clone for AnnotatedOutput
impl Clone for AnnotatedOutput
Source§fn clone(&self) -> AnnotatedOutput
fn clone(&self) -> AnnotatedOutput
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AnnotatedOutput
impl Debug for AnnotatedOutput
Source§impl<'de> Deserialize<'de> for AnnotatedOutput
impl<'de> Deserialize<'de> for AnnotatedOutput
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>,
Auto Trait Implementations§
impl Freeze for AnnotatedOutput
impl RefUnwindSafe for AnnotatedOutput
impl Send for AnnotatedOutput
impl Sync for AnnotatedOutput
impl Unpin for AnnotatedOutput
impl UnsafeUnpin for AnnotatedOutput
impl UnwindSafe for AnnotatedOutput
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more