Skip to main content

aws_sdk_wafv2/types/
_label.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>A single label container. This is used as an element of a label array in multiple contexts, for example, in <code>RuleLabels</code> inside a <code>Rule</code> and in <code>Labels</code> inside a <code>SampledHTTPRequest</code>.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct Label {
7    /// <p>The label string.</p>
8    pub name: ::std::string::String,
9}
10impl Label {
11    /// <p>The label string.</p>
12    pub fn name(&self) -> &str {
13        use std::ops::Deref;
14        self.name.deref()
15    }
16}
17impl Label {
18    /// Creates a new builder-style object to manufacture [`Label`](crate::types::Label).
19    pub fn builder() -> crate::types::builders::LabelBuilder {
20        crate::types::builders::LabelBuilder::default()
21    }
22}
23
24/// A builder for [`Label`](crate::types::Label).
25#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
26#[non_exhaustive]
27pub struct LabelBuilder {
28    pub(crate) name: ::std::option::Option<::std::string::String>,
29}
30impl LabelBuilder {
31    /// <p>The label string.</p>
32    /// This field is required.
33    pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
34        self.name = ::std::option::Option::Some(input.into());
35        self
36    }
37    /// <p>The label string.</p>
38    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
39        self.name = input;
40        self
41    }
42    /// <p>The label string.</p>
43    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
44        &self.name
45    }
46    /// Consumes the builder and constructs a [`Label`](crate::types::Label).
47    /// This method will fail if any of the following fields are not set:
48    /// - [`name`](crate::types::builders::LabelBuilder::name)
49    pub fn build(self) -> ::std::result::Result<crate::types::Label, ::aws_smithy_types::error::operation::BuildError> {
50        ::std::result::Result::Ok(crate::types::Label {
51            name: self.name.ok_or_else(|| {
52                ::aws_smithy_types::error::operation::BuildError::missing_field(
53                    "name",
54                    "name was not specified but it is required when building Label",
55                )
56            })?,
57        })
58    }
59}