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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// <p>Information about each word or line of text in the input document.</p>
/// <p>For additional information, see <a href="https://docs.aws.amazon.com/textract/latest/dg/API_Block.html">Block</a> in the Amazon Textract API reference.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Block {
/// <p>Unique identifier for the block.</p>
pub id: ::std::option::Option<::std::string::String>,
/// <p>The block represents a line of text or one word of text.</p>
/// <ul>
/// <li>
/// <p>WORD - A word that's detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.</p></li>
/// <li>
/// <p>LINE - A string of tab-delimited, contiguous words that are detected on a document page</p></li>
/// </ul>
pub block_type: ::std::option::Option<crate::types::BlockType>,
/// <p>The word or line of text extracted from the block.</p>
pub text: ::std::option::Option<::std::string::String>,
/// <p>Page number where the block appears.</p>
pub page: ::std::option::Option<i32>,
/// <p>Co-ordinates of the rectangle or polygon that contains the text.</p>
pub geometry: ::std::option::Option<crate::types::Geometry>,
/// <p>A list of child blocks of the current block. For example, a LINE object has child blocks for each WORD block that's part of the line of text.</p>
pub relationships: ::std::option::Option<::std::vec::Vec<crate::types::RelationshipsListItem>>,
}
impl Block {
/// <p>Unique identifier for the block.</p>
pub fn id(&self) -> ::std::option::Option<&str> {
self.id.as_deref()
}
/// <p>The block represents a line of text or one word of text.</p>
/// <ul>
/// <li>
/// <p>WORD - A word that's detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.</p></li>
/// <li>
/// <p>LINE - A string of tab-delimited, contiguous words that are detected on a document page</p></li>
/// </ul>
pub fn block_type(&self) -> ::std::option::Option<&crate::types::BlockType> {
self.block_type.as_ref()
}
/// <p>The word or line of text extracted from the block.</p>
pub fn text(&self) -> ::std::option::Option<&str> {
self.text.as_deref()
}
/// <p>Page number where the block appears.</p>
pub fn page(&self) -> ::std::option::Option<i32> {
self.page
}
/// <p>Co-ordinates of the rectangle or polygon that contains the text.</p>
pub fn geometry(&self) -> ::std::option::Option<&crate::types::Geometry> {
self.geometry.as_ref()
}
/// <p>A list of child blocks of the current block. For example, a LINE object has child blocks for each WORD block that's part of the line of text.</p>
///
/// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.relationships.is_none()`.
pub fn relationships(&self) -> &[crate::types::RelationshipsListItem] {
self.relationships.as_deref().unwrap_or_default()
}
}
impl Block {
/// Creates a new builder-style object to manufacture [`Block`](crate::types::Block).
pub fn builder() -> crate::types::builders::BlockBuilder {
crate::types::builders::BlockBuilder::default()
}
}
/// A builder for [`Block`](crate::types::Block).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct BlockBuilder {
pub(crate) id: ::std::option::Option<::std::string::String>,
pub(crate) block_type: ::std::option::Option<crate::types::BlockType>,
pub(crate) text: ::std::option::Option<::std::string::String>,
pub(crate) page: ::std::option::Option<i32>,
pub(crate) geometry: ::std::option::Option<crate::types::Geometry>,
pub(crate) relationships: ::std::option::Option<::std::vec::Vec<crate::types::RelationshipsListItem>>,
}
impl BlockBuilder {
/// <p>Unique identifier for the block.</p>
pub fn id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.id = ::std::option::Option::Some(input.into());
self
}
/// <p>Unique identifier for the block.</p>
pub fn set_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.id = input;
self
}
/// <p>Unique identifier for the block.</p>
pub fn get_id(&self) -> &::std::option::Option<::std::string::String> {
&self.id
}
/// <p>The block represents a line of text or one word of text.</p>
/// <ul>
/// <li>
/// <p>WORD - A word that's detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.</p></li>
/// <li>
/// <p>LINE - A string of tab-delimited, contiguous words that are detected on a document page</p></li>
/// </ul>
pub fn block_type(mut self, input: crate::types::BlockType) -> Self {
self.block_type = ::std::option::Option::Some(input);
self
}
/// <p>The block represents a line of text or one word of text.</p>
/// <ul>
/// <li>
/// <p>WORD - A word that's detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.</p></li>
/// <li>
/// <p>LINE - A string of tab-delimited, contiguous words that are detected on a document page</p></li>
/// </ul>
pub fn set_block_type(mut self, input: ::std::option::Option<crate::types::BlockType>) -> Self {
self.block_type = input;
self
}
/// <p>The block represents a line of text or one word of text.</p>
/// <ul>
/// <li>
/// <p>WORD - A word that's detected on a document page. A word is one or more ISO basic Latin script characters that aren't separated by spaces.</p></li>
/// <li>
/// <p>LINE - A string of tab-delimited, contiguous words that are detected on a document page</p></li>
/// </ul>
pub fn get_block_type(&self) -> &::std::option::Option<crate::types::BlockType> {
&self.block_type
}
/// <p>The word or line of text extracted from the block.</p>
pub fn text(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.text = ::std::option::Option::Some(input.into());
self
}
/// <p>The word or line of text extracted from the block.</p>
pub fn set_text(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.text = input;
self
}
/// <p>The word or line of text extracted from the block.</p>
pub fn get_text(&self) -> &::std::option::Option<::std::string::String> {
&self.text
}
/// <p>Page number where the block appears.</p>
pub fn page(mut self, input: i32) -> Self {
self.page = ::std::option::Option::Some(input);
self
}
/// <p>Page number where the block appears.</p>
pub fn set_page(mut self, input: ::std::option::Option<i32>) -> Self {
self.page = input;
self
}
/// <p>Page number where the block appears.</p>
pub fn get_page(&self) -> &::std::option::Option<i32> {
&self.page
}
/// <p>Co-ordinates of the rectangle or polygon that contains the text.</p>
pub fn geometry(mut self, input: crate::types::Geometry) -> Self {
self.geometry = ::std::option::Option::Some(input);
self
}
/// <p>Co-ordinates of the rectangle or polygon that contains the text.</p>
pub fn set_geometry(mut self, input: ::std::option::Option<crate::types::Geometry>) -> Self {
self.geometry = input;
self
}
/// <p>Co-ordinates of the rectangle or polygon that contains the text.</p>
pub fn get_geometry(&self) -> &::std::option::Option<crate::types::Geometry> {
&self.geometry
}
/// Appends an item to `relationships`.
///
/// To override the contents of this collection use [`set_relationships`](Self::set_relationships).
///
/// <p>A list of child blocks of the current block. For example, a LINE object has child blocks for each WORD block that's part of the line of text.</p>
pub fn relationships(mut self, input: crate::types::RelationshipsListItem) -> Self {
let mut v = self.relationships.unwrap_or_default();
v.push(input);
self.relationships = ::std::option::Option::Some(v);
self
}
/// <p>A list of child blocks of the current block. For example, a LINE object has child blocks for each WORD block that's part of the line of text.</p>
pub fn set_relationships(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::RelationshipsListItem>>) -> Self {
self.relationships = input;
self
}
/// <p>A list of child blocks of the current block. For example, a LINE object has child blocks for each WORD block that's part of the line of text.</p>
pub fn get_relationships(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::RelationshipsListItem>> {
&self.relationships
}
/// Consumes the builder and constructs a [`Block`](crate::types::Block).
pub fn build(self) -> crate::types::Block {
crate::types::Block {
id: self.id,
block_type: self.block_type,
text: self.text,
page: self.page,
geometry: self.geometry,
relationships: self.relationships,
}
}
}