Skip to main content

aws_sdk_directconnect/types/
_tag.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Information about a tag.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct Tag {
7    /// <p>The key.</p>
8    pub key: ::std::string::String,
9    /// <p>The value.</p>
10    pub value: ::std::option::Option<::std::string::String>,
11}
12impl Tag {
13    /// <p>The key.</p>
14    pub fn key(&self) -> &str {
15        use std::ops::Deref;
16        self.key.deref()
17    }
18    /// <p>The value.</p>
19    pub fn value(&self) -> ::std::option::Option<&str> {
20        self.value.as_deref()
21    }
22}
23impl Tag {
24    /// Creates a new builder-style object to manufacture [`Tag`](crate::types::Tag).
25    pub fn builder() -> crate::types::builders::TagBuilder {
26        crate::types::builders::TagBuilder::default()
27    }
28}
29
30/// A builder for [`Tag`](crate::types::Tag).
31#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
32#[non_exhaustive]
33pub struct TagBuilder {
34    pub(crate) key: ::std::option::Option<::std::string::String>,
35    pub(crate) value: ::std::option::Option<::std::string::String>,
36}
37impl TagBuilder {
38    /// <p>The key.</p>
39    /// This field is required.
40    pub fn key(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
41        self.key = ::std::option::Option::Some(input.into());
42        self
43    }
44    /// <p>The key.</p>
45    pub fn set_key(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
46        self.key = input;
47        self
48    }
49    /// <p>The key.</p>
50    pub fn get_key(&self) -> &::std::option::Option<::std::string::String> {
51        &self.key
52    }
53    /// <p>The value.</p>
54    pub fn value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
55        self.value = ::std::option::Option::Some(input.into());
56        self
57    }
58    /// <p>The value.</p>
59    pub fn set_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
60        self.value = input;
61        self
62    }
63    /// <p>The value.</p>
64    pub fn get_value(&self) -> &::std::option::Option<::std::string::String> {
65        &self.value
66    }
67    /// Consumes the builder and constructs a [`Tag`](crate::types::Tag).
68    /// This method will fail if any of the following fields are not set:
69    /// - [`key`](crate::types::builders::TagBuilder::key)
70    pub fn build(self) -> ::std::result::Result<crate::types::Tag, ::aws_smithy_types::error::operation::BuildError> {
71        ::std::result::Result::Ok(crate::types::Tag {
72            key: self.key.ok_or_else(|| {
73                ::aws_smithy_types::error::operation::BuildError::missing_field("key", "key was not specified but it is required when building Tag")
74            })?,
75            value: self.value,
76        })
77    }
78}