pub struct SpanTree;Expand description
A hierarchical span tree component for trace visualization.
Displays hierarchical spans with horizontal timing bars aligned to a shared time axis. Each row shows a label with tree expand/collapse indicators on the left, and a proportional duration bar on the right.
§Visual Format
┌─ Trace ─────────────────────────────────────────┐
│ Label │ 0ms 500ms 1000ms│
│───────────────────────────┼──────────────────────│
│ ▾ frontend/request │ ████████████████████ │
│ ▾ api/handler │ ██████████████ │
│ db/query │ ████ │
│ cache/lookup │ ███ │
│ auth/validate │ ███ │
└─────────────────────────────────────────────────┘§Keyboard Navigation
Up/k: Move selection upDown/j: Move selection downRight/l: Expand selected nodeLeft/h: Collapse selected nodeSpace/Enter: Toggle expand/collapseShift+Right: Increase label widthShift+Left: Decrease label width
§Example
use envision::component::{
Component, SpanTree, SpanTreeState, SpanTreeMessage, SpanNode,
};
use ratatui::style::Color;
let root = SpanNode::new("req", "frontend/request", 0.0, 1000.0)
.with_color(Color::Cyan)
.with_child(
SpanNode::new("api", "api/handler", 50.0, 800.0)
.with_color(Color::Yellow)
.with_child(SpanNode::new("db", "db/query", 100.0, 400.0).with_color(Color::Green))
);
let mut state = SpanTreeState::new(vec![root]);
// Navigate through spans
SpanTree::update(&mut state, SpanTreeMessage::SelectDown);
SpanTree::update(&mut state, SpanTreeMessage::Collapse);Trait Implementations§
Source§impl Component for SpanTree
impl Component for SpanTree
Source§type State = SpanTreeState
type State = SpanTreeState
The component’s internal state type. Read more
Source§type Message = SpanTreeMessage
type Message = SpanTreeMessage
Messages this component can receive. Read more
Source§type Output = SpanTreeOutput
type Output = SpanTreeOutput
Messages this component can emit to its parent. Read more
Source§fn update(state: &mut Self::State, msg: Self::Message) -> Option<Self::Output>
fn update(state: &mut Self::State, msg: Self::Message) -> Option<Self::Output>
Update component state based on a message. Read more
Source§fn handle_event(
state: &Self::State,
event: &Event,
ctx: &EventContext,
) -> Option<Self::Message>
fn handle_event( state: &Self::State, event: &Event, ctx: &EventContext, ) -> Option<Self::Message>
Maps an input event to a component message. Read more
Source§fn view(state: &Self::State, ctx: &mut RenderContext<'_, '_>)
fn view(state: &Self::State, ctx: &mut RenderContext<'_, '_>)
Render the component to the given area. Read more
Source§fn traced_view(state: &Self::State, ctx: &mut RenderContext<'_, '_>)
fn traced_view(state: &Self::State, ctx: &mut RenderContext<'_, '_>)
Renders the component with optional tracing instrumentation. Read more
Source§fn dispatch_event(
state: &mut Self::State,
event: &Event,
ctx: &EventContext,
) -> Option<Self::Output>
fn dispatch_event( state: &mut Self::State, event: &Event, ctx: &EventContext, ) -> Option<Self::Output>
Dispatches an event by mapping it to a message and updating state. Read more
Auto Trait Implementations§
impl Freeze for SpanTree
impl RefUnwindSafe for SpanTree
impl Send for SpanTree
impl Sync for SpanTree
impl Unpin for SpanTree
impl UnsafeUnpin for SpanTree
impl UnwindSafe for SpanTree
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> 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>
Converts
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>
Converts
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