Skip to content

Commit bc55504

Browse files
add serde support on meta data
1 parent 3aa4cc2 commit bc55504

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

rust-runtime/aws-smithy-types/src/error/metadata.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//! Error metadata
77
88
use crate::retry::{ErrorKind, ProvideErrorKind};
9+
use std::borrow::Cow;
910
use std::collections::HashMap;
1011
use std::fmt;
1112

@@ -39,11 +40,19 @@ pub const EMPTY_ERROR_METADATA: ErrorMetadata = ErrorMetadata {
3940
/// For many services, Errors are modeled. However, many services only partially model errors or don't
4041
/// model errors at all. In these cases, the SDK will return this generic error type to expose the
4142
/// `code`, `message` and `request_id`.
43+
#[cfg_attr(
44+
all(aws_sdk_unstable, feature = "serde-serialize"),
45+
derive(serde::Serialize)
46+
)]
47+
#[cfg_attr(
48+
all(aws_sdk_unstable, feature = "serde-deserialize"),
49+
derive(serde::Deserialize)
50+
)]
4251
#[derive(Debug, Eq, PartialEq, Default, Clone)]
4352
pub struct ErrorMetadata {
4453
code: Option<String>,
4554
message: Option<String>,
46-
extras: Option<HashMap<&'static str, String>>,
55+
extras: Option<HashMap<Cow<'static, str>, String>>,
4756
}
4857

4958
/// Builder for [`ErrorMetadata`].
@@ -98,7 +107,7 @@ impl Builder {
98107
.extras
99108
.as_mut()
100109
.unwrap()
101-
.insert(key, value.into());
110+
.insert(Cow::Borrowed(key), value.into());
102111
self
103112
}
104113

0 commit comments

Comments
 (0)