aws_smithy_http_server/
shape_id.rs

1/*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6//! A [`ShapeId`] represents a [Smithy Shape ID](https://smithy.io/2.0/spec/model.html#shape-id).
7//!
8//! # Example
9//!
10//! In the following model:
11//!
12//! ```smithy
13//! namespace smithy.example
14//!
15//! operation CheckHealth {}
16//! ```
17//!
18//! - `absolute` is `"smithy.example#CheckHealth"`
19//! - `namespace` is `"smithy.example"`
20//! - `name` is `"CheckHealth"`
21
22pub use crate::request::extension::{Extension, MissingExtension};
23
24/// Represents a [Smithy Shape ID](https://smithy.io/2.0/spec/model.html#shape-id).
25#[derive(Debug, Clone, PartialEq, Eq, Hash)]
26pub struct ShapeId {
27    absolute: &'static str,
28
29    namespace: &'static str,
30    name: &'static str,
31}
32
33impl ShapeId {
34    /// Constructs a new [`ShapeId`]. This is used by the code-generator which preserves the invariants of the Shape ID format.
35    #[doc(hidden)]
36    pub const fn new(absolute: &'static str, namespace: &'static str, name: &'static str) -> Self {
37        Self {
38            absolute,
39            namespace,
40            name,
41        }
42    }
43
44    /// Returns the namespace.
45    ///
46    /// See [Shape ID](https://smithy.io/2.0/spec/model.html#shape-id) for a breakdown of the syntax.
47    pub fn namespace(&self) -> &'static str {
48        self.namespace
49    }
50
51    /// Returns the member name.
52    ///
53    /// See [Shape ID](https://smithy.io/2.0/spec/model.html#shape-id) for a breakdown of the syntax.
54    pub fn name(&self) -> &'static str {
55        self.name
56    }
57
58    /// Returns the absolute shape ID.
59    ///
60    /// See [Shape ID](https://smithy.io/2.0/spec/model.html#shape-id) for a breakdown of the syntax.
61    pub fn absolute(&self) -> &'static str {
62        self.absolute
63    }
64}