use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::object_id::ObjectId;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
#[non_exhaustive]
pub enum PathFieldCommand {
FileName,
Path,
PathAndFileName,
Unknown(String),
}
impl PathFieldCommand {
pub fn wire_command(&self) -> &str {
match self {
Self::FileName => "$F",
Self::Path => "$P",
Self::PathAndFileName => "$P$F",
Self::Unknown(s) => s.as_str(),
}
}
pub fn from_wire(cmd: &str) -> Self {
match cmd {
"$F" => Self::FileName,
"$P" => Self::Path,
"$P$F" => Self::PathAndFileName,
other => Self::Unknown(other.to_string()),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
#[non_exhaustive]
pub enum RefTarget {
Name(String),
Object(ObjectId),
Raw(String),
}
impl RefTarget {
pub fn as_display(&self) -> String {
match self {
Self::Name(s) => s.clone(),
Self::Object(id) => format!("#{id}"),
Self::Raw(s) => s.clone(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
#[non_exhaustive]
pub enum InlinePageKind {
CurrentPage,
TotalPages,
Unknown,
}