Skip to main content

canic_core/ids/
endpoint.rs

1//! Module: ids::endpoint
2//!
3//! Responsibility: endpoint identifiers and call-kind labels.
4//! Does not own: endpoint dispatch, authorization, or metrics emission.
5//! Boundary: provides small typed values used by replay and observability code.
6
7///
8/// EndpointCall
9///
10/// One named endpoint invocation and its IC call mode.
11///
12
13#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
14pub struct EndpointCall {
15    pub endpoint: EndpointId,
16    pub kind: EndpointCallKind,
17}
18
19///
20/// EndpointCallKind
21///
22/// IC endpoint call mode used for replay and metrics labels.
23///
24
25#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub enum EndpointCallKind {
27    Query,
28    QueryComposite,
29    Update,
30}
31
32impl EndpointCallKind {
33    #[must_use]
34    pub const fn metric_label(self) -> &'static str {
35        match self {
36            Self::Query => "query",
37            Self::QueryComposite => "composite_query",
38            Self::Update => "update",
39        }
40    }
41}
42
43///
44/// EndpointId
45///
46/// Static endpoint name carried through replay and observability paths.
47///
48
49#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
50pub struct EndpointId {
51    pub name: &'static str,
52}
53
54impl EndpointId {
55    #[must_use]
56    pub const fn new(name: &'static str) -> Self {
57        Self { name }
58    }
59}