1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

//! A [`ShapeId`] represents a [Smithy Shape ID](https://smithy.io/2.0/spec/model.html#shape-id).
//!
//! # Example
//!
//! In the following model:
//!
//! ```smithy
//! namespace smithy.example
//!
//! operation CheckHealth {}
//! ```
//!
//! - `absolute` is `"smithy.example#CheckHealth"`
//! - `namespace` is `"smithy.example"`
//! - `name` is `"CheckHealth"`

pub use crate::request::extension::{Extension, MissingExtension};

/// Represents a [Smithy Shape ID](https://smithy.io/2.0/spec/model.html#shape-id).
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ShapeId {
    absolute: &'static str,

    namespace: &'static str,
    name: &'static str,
}

impl ShapeId {
    /// Constructs a new [`ShapeId`]. This is used by the code-generator which preserves the invariants of the Shape ID format.
    #[doc(hidden)]
    pub const fn new(absolute: &'static str, namespace: &'static str, name: &'static str) -> Self {
        Self {
            absolute,
            namespace,
            name,
        }
    }

    /// Returns the namespace.
    ///
    /// See [Shape ID](https://smithy.io/2.0/spec/model.html#shape-id) for a breakdown of the syntax.
    pub fn namespace(&self) -> &'static str {
        self.namespace
    }

    /// Returns the member name.
    ///
    /// See [Shape ID](https://smithy.io/2.0/spec/model.html#shape-id) for a breakdown of the syntax.
    pub fn name(&self) -> &'static str {
        self.name
    }

    /// Returns the absolute shape ID.
    ///
    /// See [Shape ID](https://smithy.io/2.0/spec/model.html#shape-id) for a breakdown of the syntax.
    pub fn absolute(&self) -> &'static str {
        self.absolute
    }
}