aws_sdk_rekognition/types/
_instance.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>An instance of a label returned by Amazon Rekognition Image (<code>DetectLabels</code>) or by Amazon Rekognition Video (<code>GetLabelDetection</code>).</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct Instance {
7    /// <p>The position of the label instance on the image.</p>
8    pub bounding_box: ::std::option::Option<crate::types::BoundingBox>,
9    /// <p>The confidence that Amazon Rekognition has in the accuracy of the bounding box.</p>
10    pub confidence: ::std::option::Option<f32>,
11    /// <p>The dominant colors found in an individual instance of a label.</p>
12    pub dominant_colors: ::std::option::Option<::std::vec::Vec<crate::types::DominantColor>>,
13}
14impl Instance {
15    /// <p>The position of the label instance on the image.</p>
16    pub fn bounding_box(&self) -> ::std::option::Option<&crate::types::BoundingBox> {
17        self.bounding_box.as_ref()
18    }
19    /// <p>The confidence that Amazon Rekognition has in the accuracy of the bounding box.</p>
20    pub fn confidence(&self) -> ::std::option::Option<f32> {
21        self.confidence
22    }
23    /// <p>The dominant colors found in an individual instance of a label.</p>
24    ///
25    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.dominant_colors.is_none()`.
26    pub fn dominant_colors(&self) -> &[crate::types::DominantColor] {
27        self.dominant_colors.as_deref().unwrap_or_default()
28    }
29}
30impl Instance {
31    /// Creates a new builder-style object to manufacture [`Instance`](crate::types::Instance).
32    pub fn builder() -> crate::types::builders::InstanceBuilder {
33        crate::types::builders::InstanceBuilder::default()
34    }
35}
36
37/// A builder for [`Instance`](crate::types::Instance).
38#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
39#[non_exhaustive]
40pub struct InstanceBuilder {
41    pub(crate) bounding_box: ::std::option::Option<crate::types::BoundingBox>,
42    pub(crate) confidence: ::std::option::Option<f32>,
43    pub(crate) dominant_colors: ::std::option::Option<::std::vec::Vec<crate::types::DominantColor>>,
44}
45impl InstanceBuilder {
46    /// <p>The position of the label instance on the image.</p>
47    pub fn bounding_box(mut self, input: crate::types::BoundingBox) -> Self {
48        self.bounding_box = ::std::option::Option::Some(input);
49        self
50    }
51    /// <p>The position of the label instance on the image.</p>
52    pub fn set_bounding_box(mut self, input: ::std::option::Option<crate::types::BoundingBox>) -> Self {
53        self.bounding_box = input;
54        self
55    }
56    /// <p>The position of the label instance on the image.</p>
57    pub fn get_bounding_box(&self) -> &::std::option::Option<crate::types::BoundingBox> {
58        &self.bounding_box
59    }
60    /// <p>The confidence that Amazon Rekognition has in the accuracy of the bounding box.</p>
61    pub fn confidence(mut self, input: f32) -> Self {
62        self.confidence = ::std::option::Option::Some(input);
63        self
64    }
65    /// <p>The confidence that Amazon Rekognition has in the accuracy of the bounding box.</p>
66    pub fn set_confidence(mut self, input: ::std::option::Option<f32>) -> Self {
67        self.confidence = input;
68        self
69    }
70    /// <p>The confidence that Amazon Rekognition has in the accuracy of the bounding box.</p>
71    pub fn get_confidence(&self) -> &::std::option::Option<f32> {
72        &self.confidence
73    }
74    /// Appends an item to `dominant_colors`.
75    ///
76    /// To override the contents of this collection use [`set_dominant_colors`](Self::set_dominant_colors).
77    ///
78    /// <p>The dominant colors found in an individual instance of a label.</p>
79    pub fn dominant_colors(mut self, input: crate::types::DominantColor) -> Self {
80        let mut v = self.dominant_colors.unwrap_or_default();
81        v.push(input);
82        self.dominant_colors = ::std::option::Option::Some(v);
83        self
84    }
85    /// <p>The dominant colors found in an individual instance of a label.</p>
86    pub fn set_dominant_colors(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::DominantColor>>) -> Self {
87        self.dominant_colors = input;
88        self
89    }
90    /// <p>The dominant colors found in an individual instance of a label.</p>
91    pub fn get_dominant_colors(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::DominantColor>> {
92        &self.dominant_colors
93    }
94    /// Consumes the builder and constructs a [`Instance`](crate::types::Instance).
95    pub fn build(self) -> crate::types::Instance {
96        crate::types::Instance {
97            bounding_box: self.bounding_box,
98            confidence: self.confidence,
99            dominant_colors: self.dominant_colors,
100        }
101    }
102}