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/// Owned by ids and consumed by access, replay, and observability code.
12///
13
14#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
15pub struct EndpointCall {
16 pub endpoint: EndpointId,
17 pub kind: EndpointCallKind,
18}
19
20///
21/// EndpointCallKind
22///
23/// IC endpoint call mode used for replay and metrics labels.
24/// Owned by ids and consumed by access, replay, and observability code.
25///
26
27#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
28pub enum EndpointCallKind {
29 Query,
30 QueryComposite,
31 Update,
32}
33
34impl EndpointCallKind {
35 /// Return the stable metrics label for this endpoint call mode.
36 #[must_use]
37 pub const fn metric_label(self) -> &'static str {
38 match self {
39 Self::Query => "query",
40 Self::QueryComposite => "composite_query",
41 Self::Update => "update",
42 }
43 }
44}
45
46///
47/// EndpointId
48///
49/// Static endpoint name carried through replay and observability paths.
50/// Owned by ids and constructed by endpoint macros and tests.
51///
52
53#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
54pub struct EndpointId {
55 pub name: &'static str,
56}
57
58impl EndpointId {
59 /// Create an endpoint id from a static endpoint name.
60 #[must_use]
61 pub const fn new(name: &'static str) -> Self {
62 Self { name }
63 }
64}