use crate::timeline::event::*;
pub trait Kind {
type Event;
}
pub trait Handler<K: Kind> {
type Scope: Default;
fn on_event(&mut self, scope: &mut Self::Scope, event: &K::Event);
}
pub struct UsageKind;
impl Kind for UsageKind {
type Event = UsageEvent;
}
pub struct PingKind;
impl Kind for PingKind {
type Event = PingEvent;
}
pub struct StatusKind;
impl Kind for StatusKind {
type Event = StatusEvent;
}
pub struct ErrorKind;
impl Kind for ErrorKind {
type Event = ErrorEvent;
}
pub struct TextBlockKind;
impl Kind for TextBlockKind {
type Event = TextBlockEvent;
}
#[derive(Debug, Clone, PartialEq)]
pub enum TextBlockEvent {
Start(TextBlockStart),
Delta(String),
Stop(TextBlockStop),
}
#[derive(Debug, Clone, PartialEq)]
pub struct TextBlockStart {
pub index: usize,
}
#[derive(Debug, Clone, PartialEq)]
pub struct TextBlockStop {
pub index: usize,
pub stop_reason: Option<StopReason>,
}
pub struct ThinkingBlockKind;
impl Kind for ThinkingBlockKind {
type Event = ThinkingBlockEvent;
}
#[derive(Debug, Clone, PartialEq)]
pub enum ThinkingBlockEvent {
Start(ThinkingBlockStart),
Delta(String),
Stop(ThinkingBlockStop),
}
#[derive(Debug, Clone, PartialEq)]
pub struct ThinkingBlockStart {
pub index: usize,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ThinkingBlockStop {
pub index: usize,
}
pub struct ToolUseBlockKind;
impl Kind for ToolUseBlockKind {
type Event = ToolUseBlockEvent;
}
#[derive(Debug, Clone, PartialEq)]
pub enum ToolUseBlockEvent {
Start(ToolUseBlockStart),
InputJsonDelta(String),
Stop(ToolUseBlockStop),
}
#[derive(Debug, Clone, PartialEq)]
pub struct ToolUseBlockStart {
pub index: usize,
pub id: String,
pub name: String,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ToolUseBlockStop {
pub index: usize,
pub id: String,
pub name: String,
}