pub struct TimelineSpan {
pub id: String,
pub start: f64,
pub end: f64,
pub label: String,
pub color: Color,
pub lane: usize,
}Expand description
A span (duration) on the timeline.
Represents a range of time, rendered as a horizontal bar.
§Example
use envision::component::TimelineSpan;
use ratatui::style::Color;
let span = TimelineSpan::new("s1", 100.0, 500.0, "HTTP Request")
.with_color(Color::Cyan)
.with_lane(1);
assert_eq!(span.id, "s1");
assert_eq!(span.start, 100.0);
assert_eq!(span.end, 500.0);
assert_eq!(span.duration(), 400.0);
assert_eq!(span.lane, 1);Fields§
§id: StringUnique identifier.
start: f64Start timestamp.
end: f64End timestamp.
label: StringDisplay label.
color: ColorColor for this span bar.
lane: usizeOptional row/lane index for vertical positioning.
Implementations§
Source§impl TimelineSpan
impl TimelineSpan
Sourcepub fn new(
id: impl Into<String>,
start: f64,
end: f64,
label: impl Into<String>,
) -> Self
pub fn new( id: impl Into<String>, start: f64, end: f64, label: impl Into<String>, ) -> Self
Creates a new timeline span with default color and lane 0.
§Example
use envision::component::TimelineSpan;
use ratatui::style::Color;
let span = TimelineSpan::new("s1", 200.0, 800.0, "request-1");
assert_eq!(span.id, "s1");
assert_eq!(span.start, 200.0);
assert_eq!(span.end, 800.0);
assert_eq!(span.label, "request-1");
assert_eq!(span.color, Color::Cyan);
assert_eq!(span.lane, 0);Sourcepub fn with_color(self, color: Color) -> Self
pub fn with_color(self, color: Color) -> Self
Sets the color (builder pattern).
§Example
use envision::component::TimelineSpan;
use ratatui::style::Color;
let span = TimelineSpan::new("s1", 0.0, 100.0, "task")
.with_color(Color::Red);
assert_eq!(span.color, Color::Red);Sourcepub fn set_color(&mut self, color: Color)
pub fn set_color(&mut self, color: Color)
Sets the color.
§Example
use envision::component::TimelineSpan;
use ratatui::style::Color;
let mut span = TimelineSpan::new("s1", 0.0, 100.0, "task");
span.set_color(Color::Red);
assert_eq!(span.color, Color::Red);Sourcepub fn color(&self) -> Color
pub fn color(&self) -> Color
Returns the color for this span bar.
§Example
use envision::component::TimelineSpan;
use ratatui::style::Color;
let span = TimelineSpan::new("s1", 0.0, 100.0, "task").with_color(Color::Red);
assert_eq!(span.color(), Color::Red);Trait Implementations§
Source§impl Clone for TimelineSpan
impl Clone for TimelineSpan
Source§fn clone(&self) -> TimelineSpan
fn clone(&self) -> TimelineSpan
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 TimelineSpan
impl Debug for TimelineSpan
Source§impl<'de> Deserialize<'de> for TimelineSpan
impl<'de> Deserialize<'de> for TimelineSpan
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 PartialEq for TimelineSpan
impl PartialEq for TimelineSpan
Source§impl Serialize for TimelineSpan
impl Serialize for TimelineSpan
impl StructuralPartialEq for TimelineSpan
Auto Trait Implementations§
impl Freeze for TimelineSpan
impl RefUnwindSafe for TimelineSpan
impl Send for TimelineSpan
impl Sync for TimelineSpan
impl Unpin for TimelineSpan
impl UnsafeUnpin for TimelineSpan
impl UnwindSafe for TimelineSpan
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<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