Skip to main content

canic_core/ids/
endpoint.rs

1///
2/// EndpointCall
3///
4
5#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
6pub struct EndpointCall {
7    pub endpoint: EndpointId,
8    pub kind: EndpointCallKind,
9}
10
11///
12/// EndpointCallKind
13///
14
15#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
16pub enum EndpointCallKind {
17    Query,
18    QueryComposite,
19    Update,
20}
21
22impl EndpointCallKind {
23    #[must_use]
24    pub const fn metric_label(self) -> &'static str {
25        match self {
26            Self::Query => "query",
27            Self::QueryComposite => "composite_query",
28            Self::Update => "update",
29        }
30    }
31}
32
33///
34/// EndpointId
35///
36
37#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
38pub struct EndpointId {
39    pub name: &'static str,
40}
41
42impl EndpointId {
43    #[must_use]
44    pub const fn new(name: &'static str) -> Self {
45        Self { name }
46    }
47}