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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// <p>Maps a span of the answer to the entities that support it. The span is answer\[startIndex:endIndex\].</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Citation {
/// <p>The character offset in <code>answer</code> where the cited span begins.</p>
pub start_index: i32,
/// <p>The character offset in <code>answer</code> where the cited span ends (exclusive).</p>
pub end_index: i32,
/// <p>The entities in retrievedContext that support the span, referenced by identity.</p>
pub references: ::std::vec::Vec<crate::types::Reference>,
}
impl Citation {
/// <p>The character offset in <code>answer</code> where the cited span begins.</p>
pub fn start_index(&self) -> i32 {
self.start_index
}
/// <p>The character offset in <code>answer</code> where the cited span ends (exclusive).</p>
pub fn end_index(&self) -> i32 {
self.end_index
}
/// <p>The entities in retrievedContext that support the span, referenced by identity.</p>
pub fn references(&self) -> &[crate::types::Reference] {
use std::ops::Deref;
self.references.deref()
}
}
impl Citation {
/// Creates a new builder-style object to manufacture [`Citation`](crate::types::Citation).
pub fn builder() -> crate::types::builders::CitationBuilder {
crate::types::builders::CitationBuilder::default()
}
}
/// A builder for [`Citation`](crate::types::Citation).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct CitationBuilder {
pub(crate) start_index: ::std::option::Option<i32>,
pub(crate) end_index: ::std::option::Option<i32>,
pub(crate) references: ::std::option::Option<::std::vec::Vec<crate::types::Reference>>,
}
impl CitationBuilder {
/// <p>The character offset in <code>answer</code> where the cited span begins.</p>
/// This field is required.
pub fn start_index(mut self, input: i32) -> Self {
self.start_index = ::std::option::Option::Some(input);
self
}
/// <p>The character offset in <code>answer</code> where the cited span begins.</p>
pub fn set_start_index(mut self, input: ::std::option::Option<i32>) -> Self {
self.start_index = input;
self
}
/// <p>The character offset in <code>answer</code> where the cited span begins.</p>
pub fn get_start_index(&self) -> &::std::option::Option<i32> {
&self.start_index
}
/// <p>The character offset in <code>answer</code> where the cited span ends (exclusive).</p>
/// This field is required.
pub fn end_index(mut self, input: i32) -> Self {
self.end_index = ::std::option::Option::Some(input);
self
}
/// <p>The character offset in <code>answer</code> where the cited span ends (exclusive).</p>
pub fn set_end_index(mut self, input: ::std::option::Option<i32>) -> Self {
self.end_index = input;
self
}
/// <p>The character offset in <code>answer</code> where the cited span ends (exclusive).</p>
pub fn get_end_index(&self) -> &::std::option::Option<i32> {
&self.end_index
}
/// Appends an item to `references`.
///
/// To override the contents of this collection use [`set_references`](Self::set_references).
///
/// <p>The entities in retrievedContext that support the span, referenced by identity.</p>
pub fn references(mut self, input: crate::types::Reference) -> Self {
let mut v = self.references.unwrap_or_default();
v.push(input);
self.references = ::std::option::Option::Some(v);
self
}
/// <p>The entities in retrievedContext that support the span, referenced by identity.</p>
pub fn set_references(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Reference>>) -> Self {
self.references = input;
self
}
/// <p>The entities in retrievedContext that support the span, referenced by identity.</p>
pub fn get_references(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Reference>> {
&self.references
}
/// Consumes the builder and constructs a [`Citation`](crate::types::Citation).
/// This method will fail if any of the following fields are not set:
/// - [`start_index`](crate::types::builders::CitationBuilder::start_index)
/// - [`end_index`](crate::types::builders::CitationBuilder::end_index)
/// - [`references`](crate::types::builders::CitationBuilder::references)
pub fn build(self) -> ::std::result::Result<crate::types::Citation, ::aws_smithy_types::error::operation::BuildError> {
::std::result::Result::Ok(crate::types::Citation {
start_index: self.start_index.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field(
"start_index",
"start_index was not specified but it is required when building Citation",
)
})?,
end_index: self.end_index.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field(
"end_index",
"end_index was not specified but it is required when building Citation",
)
})?,
references: self.references.ok_or_else(|| {
::aws_smithy_types::error::operation::BuildError::missing_field(
"references",
"references was not specified but it is required when building Citation",
)
})?,
})
}
}