use super::{GeoReplicationStatus, ListQueuesIncludeType, StorageErrorCode};
use azure_core::error::{Error, ErrorKind};
use std::{
convert::{AsRef, From, Infallible},
fmt::{Display, Formatter},
str::FromStr,
};
impl<'a> From<&'a GeoReplicationStatus> for &'a str {
fn from(e: &'a GeoReplicationStatus) -> Self {
match e {
GeoReplicationStatus::Bootstrap => "bootstrap",
GeoReplicationStatus::Live => "live",
GeoReplicationStatus::Unavailable => "unavailable",
GeoReplicationStatus::UnknownValue(s) => s.as_ref(),
}
}
}
impl FromStr for GeoReplicationStatus {
type Err = Infallible;
fn from_str(s: &str) -> ::core::result::Result<Self, <Self as FromStr>::Err> {
Ok(match s {
"bootstrap" => GeoReplicationStatus::Bootstrap,
"live" => GeoReplicationStatus::Live,
"unavailable" => GeoReplicationStatus::Unavailable,
_ => GeoReplicationStatus::UnknownValue(s.to_string()),
})
}
}
impl AsRef<str> for GeoReplicationStatus {
fn as_ref(&self) -> &str {
match self {
GeoReplicationStatus::Bootstrap => "bootstrap",
GeoReplicationStatus::Live => "live",
GeoReplicationStatus::Unavailable => "unavailable",
GeoReplicationStatus::UnknownValue(s) => s.as_str(),
}
}
}
impl Display for GeoReplicationStatus {
fn fmt(&self, f: &mut Formatter<'_>) -> ::std::fmt::Result {
match self {
GeoReplicationStatus::Bootstrap => f.write_str("bootstrap"),
GeoReplicationStatus::Live => f.write_str("live"),
GeoReplicationStatus::Unavailable => f.write_str("unavailable"),
GeoReplicationStatus::UnknownValue(s) => f.write_str(s.as_str()),
}
}
}
impl FromStr for ListQueuesIncludeType {
type Err = Error;
fn from_str(s: &str) -> ::core::result::Result<Self, <Self as FromStr>::Err> {
Ok(match s {
"metadata" => ListQueuesIncludeType::Metadata,
_ => {
return Err(Error::with_message_fn(ErrorKind::DataConversion, || {
format!("unknown variant of ListQueuesIncludeType found: \"{s}\"")
}))
}
})
}
}
impl AsRef<str> for ListQueuesIncludeType {
fn as_ref(&self) -> &str {
match self {
ListQueuesIncludeType::Metadata => "metadata",
}
}
}
impl Display for ListQueuesIncludeType {
fn fmt(&self, f: &mut Formatter<'_>) -> ::std::fmt::Result {
match self {
ListQueuesIncludeType::Metadata => Display::fmt("metadata", f),
}
}
}
impl<'a> From<&'a StorageErrorCode> for &'a str {
fn from(e: &'a StorageErrorCode) -> Self {
match e {
StorageErrorCode::AccountAlreadyExists => "AccountAlreadyExists",
StorageErrorCode::AccountBeingCreated => "AccountBeingCreated",
StorageErrorCode::AccountIsDisabled => "AccountIsDisabled",
StorageErrorCode::AuthenticationFailed => "AuthenticationFailed",
StorageErrorCode::AuthorizationFailure => "AuthorizationFailure",
StorageErrorCode::AuthorizationPermissionMismatch => "AuthorizationPermissionMismatch",
StorageErrorCode::AuthorizationProtocolMismatch => "AuthorizationProtocolMismatch",
StorageErrorCode::AuthorizationResourceTypeMismatch => {
"AuthorizationResourceTypeMismatch"
}
StorageErrorCode::AuthorizationServiceMismatch => "AuthorizationServiceMismatch",
StorageErrorCode::AuthorizationSourceIPMismatch => "AuthorizationSourceIPMismatch",
StorageErrorCode::ConditionHeadersNotSupported => "ConditionHeadersNotSupported",
StorageErrorCode::ConditionNotMet => "ConditionNotMet",
StorageErrorCode::EmptyMetadataKey => "EmptyMetadataKey",
StorageErrorCode::FeatureVersionMismatch => "FeatureVersionMismatch",
StorageErrorCode::InsufficientAccountPermissions => "InsufficientAccountPermissions",
StorageErrorCode::InternalError => "InternalError",
StorageErrorCode::InvalidAuthenticationInfo => "InvalidAuthenticationInfo",
StorageErrorCode::InvalidHeaderValue => "InvalidHeaderValue",
StorageErrorCode::InvalidHttpVerb => "InvalidHttpVerb",
StorageErrorCode::InvalidInput => "InvalidInput",
StorageErrorCode::InvalidMarker => "InvalidMarker",
StorageErrorCode::InvalidMd5 => "InvalidMd5",
StorageErrorCode::InvalidMetadata => "InvalidMetadata",
StorageErrorCode::InvalidQueryParameterValue => "InvalidQueryParameterValue",
StorageErrorCode::InvalidRange => "InvalidRange",
StorageErrorCode::InvalidResourceName => "InvalidResourceName",
StorageErrorCode::InvalidUri => "InvalidUri",
StorageErrorCode::InvalidXmlDocument => "InvalidXmlDocument",
StorageErrorCode::InvalidXmlNodeValue => "InvalidXmlNodeValue",
StorageErrorCode::Md5Mismatch => "Md5Mismatch",
StorageErrorCode::MessageNotFound => "MessageNotFound",
StorageErrorCode::MessageTooLarge => "MessageTooLarge",
StorageErrorCode::MetadataTooLarge => "MetadataTooLarge",
StorageErrorCode::MissingContentLengthHeader => "MissingContentLengthHeader",
StorageErrorCode::MissingRequiredHeader => "MissingRequiredHeader",
StorageErrorCode::MissingRequiredQueryParameter => "MissingRequiredQueryParameter",
StorageErrorCode::MissingRequiredXmlNode => "MissingRequiredXmlNode",
StorageErrorCode::MultipleConditionHeadersNotSupported => {
"MultipleConditionHeadersNotSupported"
}
StorageErrorCode::OperationTimedOut => "OperationTimedOut",
StorageErrorCode::OutOfRangeInput => "OutOfRangeInput",
StorageErrorCode::OutOfRangeQueryParameterValue => "OutOfRangeQueryParameterValue",
StorageErrorCode::PopReceiptMismatch => "PopReceiptMismatch",
StorageErrorCode::QueueAlreadyExists => "QueueAlreadyExists",
StorageErrorCode::QueueBeingDeleted => "QueueBeingDeleted",
StorageErrorCode::QueueDisabled => "QueueDisabled",
StorageErrorCode::QueueNotEmpty => "QueueNotEmpty",
StorageErrorCode::QueueNotFound => "QueueNotFound",
StorageErrorCode::RequestBodyTooLarge => "RequestBodyTooLarge",
StorageErrorCode::RequestUrlFailedToParse => "RequestUrlFailedToParse",
StorageErrorCode::ResourceAlreadyExists => "ResourceAlreadyExists",
StorageErrorCode::ResourceNotFound => "ResourceNotFound",
StorageErrorCode::ResourceTypeMismatch => "ResourceTypeMismatch",
StorageErrorCode::ServerBusy => "ServerBusy",
StorageErrorCode::UnsupportedHeader => "UnsupportedHeader",
StorageErrorCode::UnsupportedHttpVerb => "UnsupportedHttpVerb",
StorageErrorCode::UnsupportedQueryParameter => "UnsupportedQueryParameter",
StorageErrorCode::UnsupportedXmlNode => "UnsupportedXmlNode",
StorageErrorCode::UnknownValue(s) => s.as_ref(),
}
}
}
impl FromStr for StorageErrorCode {
type Err = Infallible;
fn from_str(s: &str) -> ::core::result::Result<Self, <Self as FromStr>::Err> {
Ok(match s {
"AccountAlreadyExists" => StorageErrorCode::AccountAlreadyExists,
"AccountBeingCreated" => StorageErrorCode::AccountBeingCreated,
"AccountIsDisabled" => StorageErrorCode::AccountIsDisabled,
"AuthenticationFailed" => StorageErrorCode::AuthenticationFailed,
"AuthorizationFailure" => StorageErrorCode::AuthorizationFailure,
"AuthorizationPermissionMismatch" => StorageErrorCode::AuthorizationPermissionMismatch,
"AuthorizationProtocolMismatch" => StorageErrorCode::AuthorizationProtocolMismatch,
"AuthorizationResourceTypeMismatch" => {
StorageErrorCode::AuthorizationResourceTypeMismatch
}
"AuthorizationServiceMismatch" => StorageErrorCode::AuthorizationServiceMismatch,
"AuthorizationSourceIPMismatch" => StorageErrorCode::AuthorizationSourceIPMismatch,
"ConditionHeadersNotSupported" => StorageErrorCode::ConditionHeadersNotSupported,
"ConditionNotMet" => StorageErrorCode::ConditionNotMet,
"EmptyMetadataKey" => StorageErrorCode::EmptyMetadataKey,
"FeatureVersionMismatch" => StorageErrorCode::FeatureVersionMismatch,
"InsufficientAccountPermissions" => StorageErrorCode::InsufficientAccountPermissions,
"InternalError" => StorageErrorCode::InternalError,
"InvalidAuthenticationInfo" => StorageErrorCode::InvalidAuthenticationInfo,
"InvalidHeaderValue" => StorageErrorCode::InvalidHeaderValue,
"InvalidHttpVerb" => StorageErrorCode::InvalidHttpVerb,
"InvalidInput" => StorageErrorCode::InvalidInput,
"InvalidMarker" => StorageErrorCode::InvalidMarker,
"InvalidMd5" => StorageErrorCode::InvalidMd5,
"InvalidMetadata" => StorageErrorCode::InvalidMetadata,
"InvalidQueryParameterValue" => StorageErrorCode::InvalidQueryParameterValue,
"InvalidRange" => StorageErrorCode::InvalidRange,
"InvalidResourceName" => StorageErrorCode::InvalidResourceName,
"InvalidUri" => StorageErrorCode::InvalidUri,
"InvalidXmlDocument" => StorageErrorCode::InvalidXmlDocument,
"InvalidXmlNodeValue" => StorageErrorCode::InvalidXmlNodeValue,
"Md5Mismatch" => StorageErrorCode::Md5Mismatch,
"MessageNotFound" => StorageErrorCode::MessageNotFound,
"MessageTooLarge" => StorageErrorCode::MessageTooLarge,
"MetadataTooLarge" => StorageErrorCode::MetadataTooLarge,
"MissingContentLengthHeader" => StorageErrorCode::MissingContentLengthHeader,
"MissingRequiredHeader" => StorageErrorCode::MissingRequiredHeader,
"MissingRequiredQueryParameter" => StorageErrorCode::MissingRequiredQueryParameter,
"MissingRequiredXmlNode" => StorageErrorCode::MissingRequiredXmlNode,
"MultipleConditionHeadersNotSupported" => {
StorageErrorCode::MultipleConditionHeadersNotSupported
}
"OperationTimedOut" => StorageErrorCode::OperationTimedOut,
"OutOfRangeInput" => StorageErrorCode::OutOfRangeInput,
"OutOfRangeQueryParameterValue" => StorageErrorCode::OutOfRangeQueryParameterValue,
"PopReceiptMismatch" => StorageErrorCode::PopReceiptMismatch,
"QueueAlreadyExists" => StorageErrorCode::QueueAlreadyExists,
"QueueBeingDeleted" => StorageErrorCode::QueueBeingDeleted,
"QueueDisabled" => StorageErrorCode::QueueDisabled,
"QueueNotEmpty" => StorageErrorCode::QueueNotEmpty,
"QueueNotFound" => StorageErrorCode::QueueNotFound,
"RequestBodyTooLarge" => StorageErrorCode::RequestBodyTooLarge,
"RequestUrlFailedToParse" => StorageErrorCode::RequestUrlFailedToParse,
"ResourceAlreadyExists" => StorageErrorCode::ResourceAlreadyExists,
"ResourceNotFound" => StorageErrorCode::ResourceNotFound,
"ResourceTypeMismatch" => StorageErrorCode::ResourceTypeMismatch,
"ServerBusy" => StorageErrorCode::ServerBusy,
"UnsupportedHeader" => StorageErrorCode::UnsupportedHeader,
"UnsupportedHttpVerb" => StorageErrorCode::UnsupportedHttpVerb,
"UnsupportedQueryParameter" => StorageErrorCode::UnsupportedQueryParameter,
"UnsupportedXmlNode" => StorageErrorCode::UnsupportedXmlNode,
_ => StorageErrorCode::UnknownValue(s.to_string()),
})
}
}
impl AsRef<str> for StorageErrorCode {
fn as_ref(&self) -> &str {
match self {
StorageErrorCode::AccountAlreadyExists => "AccountAlreadyExists",
StorageErrorCode::AccountBeingCreated => "AccountBeingCreated",
StorageErrorCode::AccountIsDisabled => "AccountIsDisabled",
StorageErrorCode::AuthenticationFailed => "AuthenticationFailed",
StorageErrorCode::AuthorizationFailure => "AuthorizationFailure",
StorageErrorCode::AuthorizationPermissionMismatch => "AuthorizationPermissionMismatch",
StorageErrorCode::AuthorizationProtocolMismatch => "AuthorizationProtocolMismatch",
StorageErrorCode::AuthorizationResourceTypeMismatch => {
"AuthorizationResourceTypeMismatch"
}
StorageErrorCode::AuthorizationServiceMismatch => "AuthorizationServiceMismatch",
StorageErrorCode::AuthorizationSourceIPMismatch => "AuthorizationSourceIPMismatch",
StorageErrorCode::ConditionHeadersNotSupported => "ConditionHeadersNotSupported",
StorageErrorCode::ConditionNotMet => "ConditionNotMet",
StorageErrorCode::EmptyMetadataKey => "EmptyMetadataKey",
StorageErrorCode::FeatureVersionMismatch => "FeatureVersionMismatch",
StorageErrorCode::InsufficientAccountPermissions => "InsufficientAccountPermissions",
StorageErrorCode::InternalError => "InternalError",
StorageErrorCode::InvalidAuthenticationInfo => "InvalidAuthenticationInfo",
StorageErrorCode::InvalidHeaderValue => "InvalidHeaderValue",
StorageErrorCode::InvalidHttpVerb => "InvalidHttpVerb",
StorageErrorCode::InvalidInput => "InvalidInput",
StorageErrorCode::InvalidMarker => "InvalidMarker",
StorageErrorCode::InvalidMd5 => "InvalidMd5",
StorageErrorCode::InvalidMetadata => "InvalidMetadata",
StorageErrorCode::InvalidQueryParameterValue => "InvalidQueryParameterValue",
StorageErrorCode::InvalidRange => "InvalidRange",
StorageErrorCode::InvalidResourceName => "InvalidResourceName",
StorageErrorCode::InvalidUri => "InvalidUri",
StorageErrorCode::InvalidXmlDocument => "InvalidXmlDocument",
StorageErrorCode::InvalidXmlNodeValue => "InvalidXmlNodeValue",
StorageErrorCode::Md5Mismatch => "Md5Mismatch",
StorageErrorCode::MessageNotFound => "MessageNotFound",
StorageErrorCode::MessageTooLarge => "MessageTooLarge",
StorageErrorCode::MetadataTooLarge => "MetadataTooLarge",
StorageErrorCode::MissingContentLengthHeader => "MissingContentLengthHeader",
StorageErrorCode::MissingRequiredHeader => "MissingRequiredHeader",
StorageErrorCode::MissingRequiredQueryParameter => "MissingRequiredQueryParameter",
StorageErrorCode::MissingRequiredXmlNode => "MissingRequiredXmlNode",
StorageErrorCode::MultipleConditionHeadersNotSupported => {
"MultipleConditionHeadersNotSupported"
}
StorageErrorCode::OperationTimedOut => "OperationTimedOut",
StorageErrorCode::OutOfRangeInput => "OutOfRangeInput",
StorageErrorCode::OutOfRangeQueryParameterValue => "OutOfRangeQueryParameterValue",
StorageErrorCode::PopReceiptMismatch => "PopReceiptMismatch",
StorageErrorCode::QueueAlreadyExists => "QueueAlreadyExists",
StorageErrorCode::QueueBeingDeleted => "QueueBeingDeleted",
StorageErrorCode::QueueDisabled => "QueueDisabled",
StorageErrorCode::QueueNotEmpty => "QueueNotEmpty",
StorageErrorCode::QueueNotFound => "QueueNotFound",
StorageErrorCode::RequestBodyTooLarge => "RequestBodyTooLarge",
StorageErrorCode::RequestUrlFailedToParse => "RequestUrlFailedToParse",
StorageErrorCode::ResourceAlreadyExists => "ResourceAlreadyExists",
StorageErrorCode::ResourceNotFound => "ResourceNotFound",
StorageErrorCode::ResourceTypeMismatch => "ResourceTypeMismatch",
StorageErrorCode::ServerBusy => "ServerBusy",
StorageErrorCode::UnsupportedHeader => "UnsupportedHeader",
StorageErrorCode::UnsupportedHttpVerb => "UnsupportedHttpVerb",
StorageErrorCode::UnsupportedQueryParameter => "UnsupportedQueryParameter",
StorageErrorCode::UnsupportedXmlNode => "UnsupportedXmlNode",
StorageErrorCode::UnknownValue(s) => s.as_str(),
}
}
}
impl Display for StorageErrorCode {
fn fmt(&self, f: &mut Formatter<'_>) -> ::std::fmt::Result {
match self {
StorageErrorCode::AccountAlreadyExists => f.write_str("AccountAlreadyExists"),
StorageErrorCode::AccountBeingCreated => f.write_str("AccountBeingCreated"),
StorageErrorCode::AccountIsDisabled => f.write_str("AccountIsDisabled"),
StorageErrorCode::AuthenticationFailed => f.write_str("AuthenticationFailed"),
StorageErrorCode::AuthorizationFailure => f.write_str("AuthorizationFailure"),
StorageErrorCode::AuthorizationPermissionMismatch => {
f.write_str("AuthorizationPermissionMismatch")
}
StorageErrorCode::AuthorizationProtocolMismatch => {
f.write_str("AuthorizationProtocolMismatch")
}
StorageErrorCode::AuthorizationResourceTypeMismatch => {
f.write_str("AuthorizationResourceTypeMismatch")
}
StorageErrorCode::AuthorizationServiceMismatch => {
f.write_str("AuthorizationServiceMismatch")
}
StorageErrorCode::AuthorizationSourceIPMismatch => {
f.write_str("AuthorizationSourceIPMismatch")
}
StorageErrorCode::ConditionHeadersNotSupported => {
f.write_str("ConditionHeadersNotSupported")
}
StorageErrorCode::ConditionNotMet => f.write_str("ConditionNotMet"),
StorageErrorCode::EmptyMetadataKey => f.write_str("EmptyMetadataKey"),
StorageErrorCode::FeatureVersionMismatch => f.write_str("FeatureVersionMismatch"),
StorageErrorCode::InsufficientAccountPermissions => {
f.write_str("InsufficientAccountPermissions")
}
StorageErrorCode::InternalError => f.write_str("InternalError"),
StorageErrorCode::InvalidAuthenticationInfo => f.write_str("InvalidAuthenticationInfo"),
StorageErrorCode::InvalidHeaderValue => f.write_str("InvalidHeaderValue"),
StorageErrorCode::InvalidHttpVerb => f.write_str("InvalidHttpVerb"),
StorageErrorCode::InvalidInput => f.write_str("InvalidInput"),
StorageErrorCode::InvalidMarker => f.write_str("InvalidMarker"),
StorageErrorCode::InvalidMd5 => f.write_str("InvalidMd5"),
StorageErrorCode::InvalidMetadata => f.write_str("InvalidMetadata"),
StorageErrorCode::InvalidQueryParameterValue => {
f.write_str("InvalidQueryParameterValue")
}
StorageErrorCode::InvalidRange => f.write_str("InvalidRange"),
StorageErrorCode::InvalidResourceName => f.write_str("InvalidResourceName"),
StorageErrorCode::InvalidUri => f.write_str("InvalidUri"),
StorageErrorCode::InvalidXmlDocument => f.write_str("InvalidXmlDocument"),
StorageErrorCode::InvalidXmlNodeValue => f.write_str("InvalidXmlNodeValue"),
StorageErrorCode::Md5Mismatch => f.write_str("Md5Mismatch"),
StorageErrorCode::MessageNotFound => f.write_str("MessageNotFound"),
StorageErrorCode::MessageTooLarge => f.write_str("MessageTooLarge"),
StorageErrorCode::MetadataTooLarge => f.write_str("MetadataTooLarge"),
StorageErrorCode::MissingContentLengthHeader => {
f.write_str("MissingContentLengthHeader")
}
StorageErrorCode::MissingRequiredHeader => f.write_str("MissingRequiredHeader"),
StorageErrorCode::MissingRequiredQueryParameter => {
f.write_str("MissingRequiredQueryParameter")
}
StorageErrorCode::MissingRequiredXmlNode => f.write_str("MissingRequiredXmlNode"),
StorageErrorCode::MultipleConditionHeadersNotSupported => {
f.write_str("MultipleConditionHeadersNotSupported")
}
StorageErrorCode::OperationTimedOut => f.write_str("OperationTimedOut"),
StorageErrorCode::OutOfRangeInput => f.write_str("OutOfRangeInput"),
StorageErrorCode::OutOfRangeQueryParameterValue => {
f.write_str("OutOfRangeQueryParameterValue")
}
StorageErrorCode::PopReceiptMismatch => f.write_str("PopReceiptMismatch"),
StorageErrorCode::QueueAlreadyExists => f.write_str("QueueAlreadyExists"),
StorageErrorCode::QueueBeingDeleted => f.write_str("QueueBeingDeleted"),
StorageErrorCode::QueueDisabled => f.write_str("QueueDisabled"),
StorageErrorCode::QueueNotEmpty => f.write_str("QueueNotEmpty"),
StorageErrorCode::QueueNotFound => f.write_str("QueueNotFound"),
StorageErrorCode::RequestBodyTooLarge => f.write_str("RequestBodyTooLarge"),
StorageErrorCode::RequestUrlFailedToParse => f.write_str("RequestUrlFailedToParse"),
StorageErrorCode::ResourceAlreadyExists => f.write_str("ResourceAlreadyExists"),
StorageErrorCode::ResourceNotFound => f.write_str("ResourceNotFound"),
StorageErrorCode::ResourceTypeMismatch => f.write_str("ResourceTypeMismatch"),
StorageErrorCode::ServerBusy => f.write_str("ServerBusy"),
StorageErrorCode::UnsupportedHeader => f.write_str("UnsupportedHeader"),
StorageErrorCode::UnsupportedHttpVerb => f.write_str("UnsupportedHttpVerb"),
StorageErrorCode::UnsupportedQueryParameter => f.write_str("UnsupportedQueryParameter"),
StorageErrorCode::UnsupportedXmlNode => f.write_str("UnsupportedXmlNode"),
StorageErrorCode::UnknownValue(s) => f.write_str(s.as_str()),
}
}
}