pub mod layout;
pub mod mermaid;
pub mod svg;
use std::collections::BTreeMap;
use crate::agent::AgentName;
pub use layout::{Edge, EdgeStyle, Layout, Node, NodeKind, Shape};
pub use mermaid::route_map;
pub use svg::render as render_svg;
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub enum Scope {
#[default]
Everything,
Pipeline(crate::pipeline::PipelineName),
}
impl Scope {
#[must_use]
pub fn pipeline(&self) -> Option<&crate::pipeline::PipelineName> {
match self {
Self::Everything => None,
Self::Pipeline(name) => Some(name),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Activity {
Running,
Waiting,
Failed,
}
impl Activity {
#[must_use]
pub fn class(self) -> &'static str {
match self {
Self::Running => "running",
Self::Waiting => "waiting",
Self::Failed => "failed",
}
}
}
#[derive(Debug, Clone, Default)]
pub struct Live {
pub activity: BTreeMap<AgentName, Activity>,
}
impl Live {
#[must_use]
pub fn with(mut self, agent: impl Into<AgentName>, activity: Activity) -> Self {
self.activity.insert(agent.into(), activity);
self
}
#[must_use]
pub fn is_idle(&self) -> bool {
self.activity.is_empty()
}
}