30 lines · 728 B · Rust
RawDownload
use serde::{Deserialize, Serialize};use std::fmt::{self, Display}; #[derive(Clone, Copy, Serialize, Deserialize, Debug, Eq, PartialEq, Hash)]#[serde(rename_all = "lowercase")]pub enum Role {    User,    Assistant,    System,} impl Role {    pub fn cycle(self) -> Role {        match self {            Role::User => Role::Assistant,            Role::Assistant => Role::System,            Role::System => Role::User,        }    }} impl Display for Role {    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {        match self {            Role::User => write!(f, "user"),            Role::Assistant => write!(f, "assistant"),            Role::System => write!(f, "system"),        }    }}