use super::id::Id;
use dioxus::prelude::EventHandler;
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Orientation {
#[default]
Horizontal,
Vertical,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Availability {
#[default]
Enabled,
Disabled,
Unavailable {
reason: Id,
},
}
impl Availability {
#[must_use]
pub fn guard<T: 'static>(&self, handler: Option<EventHandler<T>>) -> Option<EventHandler<T>> {
if *self == Self::Enabled {
handler
} else {
None
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Lifecycle {
Pending,
Queued,
Streaming,
Running,
Complete,
Aborted,
Denied,
Error,
}
impl Lifecycle {
pub const ALL: &'static [Self] = &[
Self::Pending,
Self::Queued,
Self::Streaming,
Self::Running,
Self::Complete,
Self::Aborted,
Self::Denied,
Self::Error,
];
#[must_use]
pub const fn is_settled(self) -> bool {
matches!(
self,
Self::Complete | Self::Aborted | Self::Denied | Self::Error
)
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Pending => "pending",
Self::Queued => "queued",
Self::Streaming => "streaming",
Self::Running => "running",
Self::Complete => "complete",
Self::Aborted => "aborted",
Self::Denied => "denied",
Self::Error => "error",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum MessageRole {
User,
Assistant,
System,
Tool,
}
impl MessageRole {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::User => "user",
Self::Assistant => "assistant",
Self::System => "system",
Self::Tool => "tool",
}
}
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum HeadingLevel {
H1,
H2,
#[default]
H3,
H4,
H5,
H6,
}