use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChatReply {
pub reply: Option<String>,
pub duration: Option<String>,
pub error: Option<String>,
}
impl ChatReply {
pub(crate) fn ok(reply: String, duration: String) -> Self {
Self {
reply: Some(reply),
duration: Some(duration),
error: None,
}
}
pub(crate) fn failed(error: impl std::fmt::Display) -> Self {
Self {
reply: None,
duration: None,
error: Some(error.to_string()),
}
}
pub fn is_ok(&self) -> bool {
self.reply.is_some()
}
}