use crate::error::{BallError, Result};
use crate::participant::Field;
pub fn field_wire_name(f: Field) -> &'static str {
match f {
Field::Title => "title",
Field::Type => "type",
Field::Priority => "priority",
Field::Status => "status",
Field::Parent => "parent",
Field::DependsOn => "depends_on",
Field::Description => "description",
Field::Tags => "tags",
Field::Notes => "notes",
Field::Links => "links",
Field::ClaimedBy => "claimed_by",
Field::Branch => "branch",
Field::ClosedAt => "closed_at",
Field::UpdatedAt => "updated_at",
Field::ClosedChildren => "closed_children",
Field::External => "external",
Field::SyncedAt => "synced_at",
Field::DeliveredIn => "delivered_in",
}
}
pub fn parse_field(name: &str) -> Result<Field> {
Ok(match name {
"title" => Field::Title,
"type" => Field::Type,
"priority" => Field::Priority,
"status" => Field::Status,
"parent" => Field::Parent,
"depends_on" => Field::DependsOn,
"description" => Field::Description,
"tags" => Field::Tags,
"notes" => Field::Notes,
"links" => Field::Links,
"claimed_by" => Field::ClaimedBy,
"branch" => Field::Branch,
"closed_at" => Field::ClosedAt,
"updated_at" => Field::UpdatedAt,
"closed_children" => Field::ClosedChildren,
"external" => Field::External,
"synced_at" => Field::SyncedAt,
"delivered_in" => Field::DeliveredIn,
other => {
return Err(BallError::Other(format!(
"unknown projection field: {other}"
)))
}
})
}