architect_api/symbology/
route.rs1use super::Symbolic;
7use crate::{uuid_val, Str};
8use anyhow::Result;
9#[cfg(feature = "netidx")]
10use derive::FromValue;
11#[cfg(feature = "netidx")]
12use netidx_derive::Pack;
13use schemars::JsonSchema;
14use serde::{Deserialize, Serialize};
15use uuid::{uuid, Uuid};
16
17static ROUTE_NS: Uuid = uuid!("0cadbcc5-98bc-4888-94ba-fbbcb6f39132");
18uuid_val!(RouteId, ROUTE_NS);
19
20#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema)]
21#[cfg_attr(feature = "juniper", derive(juniper::GraphQLObject))]
22#[cfg_attr(feature = "netidx", derive(Pack, FromValue))]
23pub struct Route {
24 pub id: RouteId,
25 pub name: Str,
26}
27
28impl Route {
29 pub fn new(name: &str) -> Result<Self> {
30 Ok(Self { id: RouteId::from(name), name: Str::try_from(name)? })
31 }
32}
33
34impl Symbolic for Route {
35 type Id = RouteId;
36
37 fn type_name() -> &'static str {
38 "route"
39 }
40
41 fn id(&self) -> Self::Id {
42 self.id
43 }
44
45 fn name(&self) -> Str {
46 self.name
47 }
48}