aws_smithy_schema/schema/
trait_type.rs1use crate::ShapeId;
7use std::any::Any;
8use std::fmt;
9
10pub trait Trait: Any + Send + Sync + fmt::Debug {
15 fn trait_id(&self) -> &ShapeId;
17
18 fn as_any(&self) -> &dyn Any;
20}
21
22#[derive(Debug, Clone)]
24#[allow(dead_code)] pub struct AnnotationTrait {
26 id: ShapeId,
27}
28
29#[allow(dead_code)]
30impl AnnotationTrait {
31 pub fn new(id: ShapeId) -> Self {
33 Self { id }
34 }
35}
36
37impl Trait for AnnotationTrait {
38 fn trait_id(&self) -> &ShapeId {
39 &self.id
40 }
41
42 fn as_any(&self) -> &dyn Any {
43 self
44 }
45}
46
47#[derive(Debug, Clone)]
49#[allow(dead_code)] pub struct StringTrait {
51 id: ShapeId,
52 value: String,
53}
54
55#[allow(dead_code)]
56impl StringTrait {
57 pub fn new(id: ShapeId, value: impl Into<String>) -> Self {
59 Self {
60 id,
61 value: value.into(),
62 }
63 }
64
65 pub fn value(&self) -> &str {
67 &self.value
68 }
69}
70
71impl Trait for StringTrait {
72 fn trait_id(&self) -> &ShapeId {
73 &self.id
74 }
75
76 fn as_any(&self) -> &dyn Any {
77 self
78 }
79}
80
81#[derive(Debug, Clone)]
86#[allow(dead_code)] pub struct DocumentTrait {
88 id: ShapeId,
89 value: aws_smithy_types::Document,
90}
91
92#[allow(dead_code)]
93impl DocumentTrait {
94 pub fn new(id: ShapeId, value: aws_smithy_types::Document) -> Self {
96 Self { id, value }
97 }
98
99 pub fn value(&self) -> &aws_smithy_types::Document {
101 &self.value
102 }
103}
104
105impl Trait for DocumentTrait {
106 fn trait_id(&self) -> &ShapeId {
107 &self.id
108 }
109
110 fn as_any(&self) -> &dyn Any {
111 self
112 }
113}