aws_sdk_ec2/types/
_tag.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Describes a tag.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct Tag {
7    /// <p>The key of the tag.</p>
8    /// <p>Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin with <code>aws:</code>.</p>
9    pub key: ::std::option::Option<::std::string::String>,
10    /// <p>The value of the tag.</p>
11    /// <p>Constraints: Tag values are case-sensitive and accept a maximum of 256 Unicode characters.</p>
12    pub value: ::std::option::Option<::std::string::String>,
13}
14impl Tag {
15    /// <p>The key of the tag.</p>
16    /// <p>Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin with <code>aws:</code>.</p>
17    pub fn key(&self) -> ::std::option::Option<&str> {
18        self.key.as_deref()
19    }
20    /// <p>The value of the tag.</p>
21    /// <p>Constraints: Tag values are case-sensitive and accept a maximum of 256 Unicode characters.</p>
22    pub fn value(&self) -> ::std::option::Option<&str> {
23        self.value.as_deref()
24    }
25}
26impl Tag {
27    /// Creates a new builder-style object to manufacture [`Tag`](crate::types::Tag).
28    pub fn builder() -> crate::types::builders::TagBuilder {
29        crate::types::builders::TagBuilder::default()
30    }
31}
32
33/// A builder for [`Tag`](crate::types::Tag).
34#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
35#[non_exhaustive]
36pub struct TagBuilder {
37    pub(crate) key: ::std::option::Option<::std::string::String>,
38    pub(crate) value: ::std::option::Option<::std::string::String>,
39}
40impl TagBuilder {
41    /// <p>The key of the tag.</p>
42    /// <p>Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin with <code>aws:</code>.</p>
43    pub fn key(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
44        self.key = ::std::option::Option::Some(input.into());
45        self
46    }
47    /// <p>The key of the tag.</p>
48    /// <p>Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin with <code>aws:</code>.</p>
49    pub fn set_key(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
50        self.key = input;
51        self
52    }
53    /// <p>The key of the tag.</p>
54    /// <p>Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin with <code>aws:</code>.</p>
55    pub fn get_key(&self) -> &::std::option::Option<::std::string::String> {
56        &self.key
57    }
58    /// <p>The value of the tag.</p>
59    /// <p>Constraints: Tag values are case-sensitive and accept a maximum of 256 Unicode characters.</p>
60    pub fn value(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
61        self.value = ::std::option::Option::Some(input.into());
62        self
63    }
64    /// <p>The value of the tag.</p>
65    /// <p>Constraints: Tag values are case-sensitive and accept a maximum of 256 Unicode characters.</p>
66    pub fn set_value(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
67        self.value = input;
68        self
69    }
70    /// <p>The value of the tag.</p>
71    /// <p>Constraints: Tag values are case-sensitive and accept a maximum of 256 Unicode characters.</p>
72    pub fn get_value(&self) -> &::std::option::Option<::std::string::String> {
73        &self.value
74    }
75    /// Consumes the builder and constructs a [`Tag`](crate::types::Tag).
76    pub fn build(self) -> crate::types::Tag {
77        crate::types::Tag {
78            key: self.key,
79            value: self.value,
80        }
81    }
82}