Skip to main content

aws_smithy_schema/schema/
shape_type.rs

1/*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6/// Enumeration of Smithy shape types.
7///
8/// This represents the core shape types from the Smithy specification,
9/// including simple types, aggregate types, and the special member type.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
11#[non_exhaustive]
12pub enum ShapeType {
13    // Simple types
14    /// Boolean type
15    Boolean,
16    /// 8-bit signed integer
17    Byte,
18    /// 16-bit signed integer
19    Short,
20    /// 32-bit signed integer
21    Integer,
22    /// 64-bit signed integer
23    Long,
24    /// 32-bit floating point
25    Float,
26    /// 64-bit floating point
27    Double,
28    /// Arbitrary precision integer
29    BigInteger,
30    /// Arbitrary precision decimal
31    BigDecimal,
32    /// UTF-8 string
33    String,
34    /// Binary data
35    Blob,
36    /// Timestamp
37    Timestamp,
38    /// Document type
39    Document,
40
41    // Aggregate types
42    /// List type
43    List,
44    /// Map type
45    Map,
46    /// Structure type
47    Structure,
48    /// Union type
49    Union,
50
51    // Member
52    /// Member shape
53    Member,
54}
55
56impl ShapeType {
57    /// Returns true if this is a simple type.
58    #[inline]
59    pub fn is_simple(&self) -> bool {
60        matches!(
61            self,
62            Self::Boolean
63                | Self::Byte
64                | Self::Short
65                | Self::Integer
66                | Self::Long
67                | Self::Float
68                | Self::Double
69                | Self::BigInteger
70                | Self::BigDecimal
71                | Self::String
72                | Self::Blob
73                | Self::Timestamp
74                | Self::Document
75        )
76    }
77
78    /// Returns true if this is an aggregate type.
79    #[inline]
80    pub fn is_aggregate(&self) -> bool {
81        matches!(self, Self::List | Self::Map | Self::Structure | Self::Union)
82    }
83
84    /// Returns true if this is a member type.
85    #[inline]
86    pub fn is_member(&self) -> bool {
87        matches!(self, Self::Member)
88    }
89}