#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(i32)]
pub enum FailureReason {
REASON_UNSPECIFIED = 0i32,
QUOTA_EXCEEDED = 1i32,
AUTHORITY_UNAVAILABLE = 2i32,
}
impl FailureReason {
#[allow(non_upper_case_globals)]
pub const ReasonUnspecified: Self = Self::REASON_UNSPECIFIED;
#[allow(non_upper_case_globals)]
pub const QuotaExceeded: Self = Self::QUOTA_EXCEEDED;
#[allow(non_upper_case_globals)]
pub const AuthorityUnavailable: Self = Self::AUTHORITY_UNAVAILABLE;
}
impl ::core::default::Default for FailureReason {
fn default() -> Self {
Self::REASON_UNSPECIFIED
}
}
impl ::serde::Serialize for FailureReason {
fn serialize<S: ::serde::Serializer>(
&self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
s.serialize_str(::buffa::Enumeration::proto_name(self))
}
}
impl<'de> ::serde::Deserialize<'de> for FailureReason {
fn deserialize<D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
struct _V;
impl ::serde::de::Visitor<'_> for _V {
type Value = FailureReason;
fn expecting(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.write_str(
concat!("a string, integer, or null for ", stringify!(FailureReason)),
)
}
fn visit_str<E: ::serde::de::Error>(
self,
v: &str,
) -> ::core::result::Result<FailureReason, E> {
<FailureReason as ::buffa::Enumeration>::from_proto_name(v)
.ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) })
}
fn visit_i64<E: ::serde::de::Error>(
self,
v: i64,
) -> ::core::result::Result<FailureReason, E> {
let v32 = i32::try_from(v)
.map_err(|_| {
::serde::de::Error::custom(
::buffa::alloc::format!("enum value {v} out of i32 range"),
)
})?;
<FailureReason as ::buffa::Enumeration>::from_i32(v32)
.ok_or_else(|| {
::serde::de::Error::custom(
::buffa::alloc::format!("unknown enum value {v32}"),
)
})
}
fn visit_u64<E: ::serde::de::Error>(
self,
v: u64,
) -> ::core::result::Result<FailureReason, E> {
let v32 = i32::try_from(v)
.map_err(|_| {
::serde::de::Error::custom(
::buffa::alloc::format!("enum value {v} out of i32 range"),
)
})?;
<FailureReason as ::buffa::Enumeration>::from_i32(v32)
.ok_or_else(|| {
::serde::de::Error::custom(
::buffa::alloc::format!("unknown enum value {v32}"),
)
})
}
fn visit_unit<E: ::serde::de::Error>(
self,
) -> ::core::result::Result<FailureReason, E> {
::core::result::Result::Ok(::core::default::Default::default())
}
}
d.deserialize_any(_V)
}
}
impl ::buffa::json_helpers::ProtoElemJson for FailureReason {
fn serialize_proto_json<S: ::serde::Serializer>(
v: &Self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
::serde::Serialize::serialize(v, s)
}
fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
<Self as ::serde::Deserialize>::deserialize(d)
}
}
impl ::buffa::Enumeration for FailureReason {
fn from_i32(value: i32) -> ::core::option::Option<Self> {
match value {
0i32 => ::core::option::Option::Some(Self::REASON_UNSPECIFIED),
1i32 => ::core::option::Option::Some(Self::QUOTA_EXCEEDED),
2i32 => ::core::option::Option::Some(Self::AUTHORITY_UNAVAILABLE),
_ => ::core::option::Option::None,
}
}
fn to_i32(&self) -> i32 {
*self as i32
}
fn proto_name(&self) -> &'static str {
match self {
Self::REASON_UNSPECIFIED => "REASON_UNSPECIFIED",
Self::QUOTA_EXCEEDED => "QUOTA_EXCEEDED",
Self::AUTHORITY_UNAVAILABLE => "AUTHORITY_UNAVAILABLE",
}
}
fn from_proto_name(name: &str) -> ::core::option::Option<Self> {
match name {
"REASON_UNSPECIFIED" => {
::core::option::Option::Some(Self::REASON_UNSPECIFIED)
}
"QUOTA_EXCEEDED" => ::core::option::Option::Some(Self::QUOTA_EXCEEDED),
"AUTHORITY_UNAVAILABLE" => {
::core::option::Option::Some(Self::AUTHORITY_UNAVAILABLE)
}
_ => ::core::option::Option::None,
}
}
fn values() -> &'static [Self] {
&[Self::REASON_UNSPECIFIED, Self::QUOTA_EXCEEDED, Self::AUTHORITY_UNAVAILABLE]
}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(i32)]
pub enum PolicyClass {
CLASS_UNSPECIFIED = 0i32,
AUTH_PUBLIC = 1i32,
TRADING_PLACE = 2i32,
TRADING_CANCEL = 3i32,
TRADING_READ = 4i32,
ACCOUNT_ADMIN = 5i32,
PUBLIC_READ = 6i32,
ACCOUNT_SECURITY = 7i32,
DEPOSIT_CREATE = 8i32,
INTERNAL_TRANSFER = 9i32,
WITHDRAW_SUBMIT = 10i32,
WITHDRAW_VALIDATE = 11i32,
GUARD_SIGN = 12i32,
SOCIAL_PROVIDER = 13i32,
}
impl PolicyClass {
#[allow(non_upper_case_globals)]
pub const ClassUnspecified: Self = Self::CLASS_UNSPECIFIED;
#[allow(non_upper_case_globals)]
pub const AuthPublic: Self = Self::AUTH_PUBLIC;
#[allow(non_upper_case_globals)]
pub const TradingPlace: Self = Self::TRADING_PLACE;
#[allow(non_upper_case_globals)]
pub const TradingCancel: Self = Self::TRADING_CANCEL;
#[allow(non_upper_case_globals)]
pub const TradingRead: Self = Self::TRADING_READ;
#[allow(non_upper_case_globals)]
pub const AccountAdmin: Self = Self::ACCOUNT_ADMIN;
#[allow(non_upper_case_globals)]
pub const PublicRead: Self = Self::PUBLIC_READ;
#[allow(non_upper_case_globals)]
pub const AccountSecurity: Self = Self::ACCOUNT_SECURITY;
#[allow(non_upper_case_globals)]
pub const DepositCreate: Self = Self::DEPOSIT_CREATE;
#[allow(non_upper_case_globals)]
pub const InternalTransfer: Self = Self::INTERNAL_TRANSFER;
#[allow(non_upper_case_globals)]
pub const WithdrawSubmit: Self = Self::WITHDRAW_SUBMIT;
#[allow(non_upper_case_globals)]
pub const WithdrawValidate: Self = Self::WITHDRAW_VALIDATE;
#[allow(non_upper_case_globals)]
pub const GuardSign: Self = Self::GUARD_SIGN;
#[allow(non_upper_case_globals)]
pub const SocialProvider: Self = Self::SOCIAL_PROVIDER;
}
impl ::core::default::Default for PolicyClass {
fn default() -> Self {
Self::CLASS_UNSPECIFIED
}
}
impl ::serde::Serialize for PolicyClass {
fn serialize<S: ::serde::Serializer>(
&self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
s.serialize_str(::buffa::Enumeration::proto_name(self))
}
}
impl<'de> ::serde::Deserialize<'de> for PolicyClass {
fn deserialize<D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
struct _V;
impl ::serde::de::Visitor<'_> for _V {
type Value = PolicyClass;
fn expecting(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.write_str(
concat!("a string, integer, or null for ", stringify!(PolicyClass)),
)
}
fn visit_str<E: ::serde::de::Error>(
self,
v: &str,
) -> ::core::result::Result<PolicyClass, E> {
<PolicyClass as ::buffa::Enumeration>::from_proto_name(v)
.ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) })
}
fn visit_i64<E: ::serde::de::Error>(
self,
v: i64,
) -> ::core::result::Result<PolicyClass, E> {
let v32 = i32::try_from(v)
.map_err(|_| {
::serde::de::Error::custom(
::buffa::alloc::format!("enum value {v} out of i32 range"),
)
})?;
<PolicyClass as ::buffa::Enumeration>::from_i32(v32)
.ok_or_else(|| {
::serde::de::Error::custom(
::buffa::alloc::format!("unknown enum value {v32}"),
)
})
}
fn visit_u64<E: ::serde::de::Error>(
self,
v: u64,
) -> ::core::result::Result<PolicyClass, E> {
let v32 = i32::try_from(v)
.map_err(|_| {
::serde::de::Error::custom(
::buffa::alloc::format!("enum value {v} out of i32 range"),
)
})?;
<PolicyClass as ::buffa::Enumeration>::from_i32(v32)
.ok_or_else(|| {
::serde::de::Error::custom(
::buffa::alloc::format!("unknown enum value {v32}"),
)
})
}
fn visit_unit<E: ::serde::de::Error>(
self,
) -> ::core::result::Result<PolicyClass, E> {
::core::result::Result::Ok(::core::default::Default::default())
}
}
d.deserialize_any(_V)
}
}
impl ::buffa::json_helpers::ProtoElemJson for PolicyClass {
fn serialize_proto_json<S: ::serde::Serializer>(
v: &Self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
::serde::Serialize::serialize(v, s)
}
fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
<Self as ::serde::Deserialize>::deserialize(d)
}
}
impl ::buffa::Enumeration for PolicyClass {
fn from_i32(value: i32) -> ::core::option::Option<Self> {
match value {
0i32 => ::core::option::Option::Some(Self::CLASS_UNSPECIFIED),
1i32 => ::core::option::Option::Some(Self::AUTH_PUBLIC),
2i32 => ::core::option::Option::Some(Self::TRADING_PLACE),
3i32 => ::core::option::Option::Some(Self::TRADING_CANCEL),
4i32 => ::core::option::Option::Some(Self::TRADING_READ),
5i32 => ::core::option::Option::Some(Self::ACCOUNT_ADMIN),
6i32 => ::core::option::Option::Some(Self::PUBLIC_READ),
7i32 => ::core::option::Option::Some(Self::ACCOUNT_SECURITY),
8i32 => ::core::option::Option::Some(Self::DEPOSIT_CREATE),
9i32 => ::core::option::Option::Some(Self::INTERNAL_TRANSFER),
10i32 => ::core::option::Option::Some(Self::WITHDRAW_SUBMIT),
11i32 => ::core::option::Option::Some(Self::WITHDRAW_VALIDATE),
12i32 => ::core::option::Option::Some(Self::GUARD_SIGN),
13i32 => ::core::option::Option::Some(Self::SOCIAL_PROVIDER),
_ => ::core::option::Option::None,
}
}
fn to_i32(&self) -> i32 {
*self as i32
}
fn proto_name(&self) -> &'static str {
match self {
Self::CLASS_UNSPECIFIED => "CLASS_UNSPECIFIED",
Self::AUTH_PUBLIC => "AUTH_PUBLIC",
Self::TRADING_PLACE => "TRADING_PLACE",
Self::TRADING_CANCEL => "TRADING_CANCEL",
Self::TRADING_READ => "TRADING_READ",
Self::ACCOUNT_ADMIN => "ACCOUNT_ADMIN",
Self::PUBLIC_READ => "PUBLIC_READ",
Self::ACCOUNT_SECURITY => "ACCOUNT_SECURITY",
Self::DEPOSIT_CREATE => "DEPOSIT_CREATE",
Self::INTERNAL_TRANSFER => "INTERNAL_TRANSFER",
Self::WITHDRAW_SUBMIT => "WITHDRAW_SUBMIT",
Self::WITHDRAW_VALIDATE => "WITHDRAW_VALIDATE",
Self::GUARD_SIGN => "GUARD_SIGN",
Self::SOCIAL_PROVIDER => "SOCIAL_PROVIDER",
}
}
fn from_proto_name(name: &str) -> ::core::option::Option<Self> {
match name {
"CLASS_UNSPECIFIED" => ::core::option::Option::Some(Self::CLASS_UNSPECIFIED),
"AUTH_PUBLIC" => ::core::option::Option::Some(Self::AUTH_PUBLIC),
"TRADING_PLACE" => ::core::option::Option::Some(Self::TRADING_PLACE),
"TRADING_CANCEL" => ::core::option::Option::Some(Self::TRADING_CANCEL),
"TRADING_READ" => ::core::option::Option::Some(Self::TRADING_READ),
"ACCOUNT_ADMIN" => ::core::option::Option::Some(Self::ACCOUNT_ADMIN),
"PUBLIC_READ" => ::core::option::Option::Some(Self::PUBLIC_READ),
"ACCOUNT_SECURITY" => ::core::option::Option::Some(Self::ACCOUNT_SECURITY),
"DEPOSIT_CREATE" => ::core::option::Option::Some(Self::DEPOSIT_CREATE),
"INTERNAL_TRANSFER" => ::core::option::Option::Some(Self::INTERNAL_TRANSFER),
"WITHDRAW_SUBMIT" => ::core::option::Option::Some(Self::WITHDRAW_SUBMIT),
"WITHDRAW_VALIDATE" => ::core::option::Option::Some(Self::WITHDRAW_VALIDATE),
"GUARD_SIGN" => ::core::option::Option::Some(Self::GUARD_SIGN),
"SOCIAL_PROVIDER" => ::core::option::Option::Some(Self::SOCIAL_PROVIDER),
_ => ::core::option::Option::None,
}
}
fn values() -> &'static [Self] {
&[
Self::CLASS_UNSPECIFIED,
Self::AUTH_PUBLIC,
Self::TRADING_PLACE,
Self::TRADING_CANCEL,
Self::TRADING_READ,
Self::ACCOUNT_ADMIN,
Self::PUBLIC_READ,
Self::ACCOUNT_SECURITY,
Self::DEPOSIT_CREATE,
Self::INTERNAL_TRANSFER,
Self::WITHDRAW_SUBMIT,
Self::WITHDRAW_VALIDATE,
Self::GUARD_SIGN,
Self::SOCIAL_PROVIDER,
]
}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(i32)]
pub enum LimiterScope {
SCOPE_UNSPECIFIED = 0i32,
CLIENT_IP = 1i32,
API_KEY = 2i32,
ACCOUNT = 3i32,
SUBACCOUNT = 4i32,
CONNECTION = 5i32,
SERVICE = 6i32,
REGION = 7i32,
SYMBOL = 8i32,
AUTH_SUBJECT = 9i32,
}
impl LimiterScope {
#[allow(non_upper_case_globals)]
pub const ScopeUnspecified: Self = Self::SCOPE_UNSPECIFIED;
#[allow(non_upper_case_globals)]
pub const ClientIp: Self = Self::CLIENT_IP;
#[allow(non_upper_case_globals)]
pub const ApiKey: Self = Self::API_KEY;
#[allow(non_upper_case_globals)]
pub const Account: Self = Self::ACCOUNT;
#[allow(non_upper_case_globals)]
pub const Subaccount: Self = Self::SUBACCOUNT;
#[allow(non_upper_case_globals)]
pub const Connection: Self = Self::CONNECTION;
#[allow(non_upper_case_globals)]
pub const Service: Self = Self::SERVICE;
#[allow(non_upper_case_globals)]
pub const Region: Self = Self::REGION;
#[allow(non_upper_case_globals)]
pub const Symbol: Self = Self::SYMBOL;
#[allow(non_upper_case_globals)]
pub const AuthSubject: Self = Self::AUTH_SUBJECT;
}
impl ::core::default::Default for LimiterScope {
fn default() -> Self {
Self::SCOPE_UNSPECIFIED
}
}
impl ::serde::Serialize for LimiterScope {
fn serialize<S: ::serde::Serializer>(
&self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
s.serialize_str(::buffa::Enumeration::proto_name(self))
}
}
impl<'de> ::serde::Deserialize<'de> for LimiterScope {
fn deserialize<D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
struct _V;
impl ::serde::de::Visitor<'_> for _V {
type Value = LimiterScope;
fn expecting(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.write_str(
concat!("a string, integer, or null for ", stringify!(LimiterScope)),
)
}
fn visit_str<E: ::serde::de::Error>(
self,
v: &str,
) -> ::core::result::Result<LimiterScope, E> {
<LimiterScope as ::buffa::Enumeration>::from_proto_name(v)
.ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) })
}
fn visit_i64<E: ::serde::de::Error>(
self,
v: i64,
) -> ::core::result::Result<LimiterScope, E> {
let v32 = i32::try_from(v)
.map_err(|_| {
::serde::de::Error::custom(
::buffa::alloc::format!("enum value {v} out of i32 range"),
)
})?;
<LimiterScope as ::buffa::Enumeration>::from_i32(v32)
.ok_or_else(|| {
::serde::de::Error::custom(
::buffa::alloc::format!("unknown enum value {v32}"),
)
})
}
fn visit_u64<E: ::serde::de::Error>(
self,
v: u64,
) -> ::core::result::Result<LimiterScope, E> {
let v32 = i32::try_from(v)
.map_err(|_| {
::serde::de::Error::custom(
::buffa::alloc::format!("enum value {v} out of i32 range"),
)
})?;
<LimiterScope as ::buffa::Enumeration>::from_i32(v32)
.ok_or_else(|| {
::serde::de::Error::custom(
::buffa::alloc::format!("unknown enum value {v32}"),
)
})
}
fn visit_unit<E: ::serde::de::Error>(
self,
) -> ::core::result::Result<LimiterScope, E> {
::core::result::Result::Ok(::core::default::Default::default())
}
}
d.deserialize_any(_V)
}
}
impl ::buffa::json_helpers::ProtoElemJson for LimiterScope {
fn serialize_proto_json<S: ::serde::Serializer>(
v: &Self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
::serde::Serialize::serialize(v, s)
}
fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
<Self as ::serde::Deserialize>::deserialize(d)
}
}
impl ::buffa::Enumeration for LimiterScope {
fn from_i32(value: i32) -> ::core::option::Option<Self> {
match value {
0i32 => ::core::option::Option::Some(Self::SCOPE_UNSPECIFIED),
1i32 => ::core::option::Option::Some(Self::CLIENT_IP),
2i32 => ::core::option::Option::Some(Self::API_KEY),
3i32 => ::core::option::Option::Some(Self::ACCOUNT),
4i32 => ::core::option::Option::Some(Self::SUBACCOUNT),
5i32 => ::core::option::Option::Some(Self::CONNECTION),
6i32 => ::core::option::Option::Some(Self::SERVICE),
7i32 => ::core::option::Option::Some(Self::REGION),
8i32 => ::core::option::Option::Some(Self::SYMBOL),
9i32 => ::core::option::Option::Some(Self::AUTH_SUBJECT),
_ => ::core::option::Option::None,
}
}
fn to_i32(&self) -> i32 {
*self as i32
}
fn proto_name(&self) -> &'static str {
match self {
Self::SCOPE_UNSPECIFIED => "SCOPE_UNSPECIFIED",
Self::CLIENT_IP => "CLIENT_IP",
Self::API_KEY => "API_KEY",
Self::ACCOUNT => "ACCOUNT",
Self::SUBACCOUNT => "SUBACCOUNT",
Self::CONNECTION => "CONNECTION",
Self::SERVICE => "SERVICE",
Self::REGION => "REGION",
Self::SYMBOL => "SYMBOL",
Self::AUTH_SUBJECT => "AUTH_SUBJECT",
}
}
fn from_proto_name(name: &str) -> ::core::option::Option<Self> {
match name {
"SCOPE_UNSPECIFIED" => ::core::option::Option::Some(Self::SCOPE_UNSPECIFIED),
"CLIENT_IP" => ::core::option::Option::Some(Self::CLIENT_IP),
"API_KEY" => ::core::option::Option::Some(Self::API_KEY),
"ACCOUNT" => ::core::option::Option::Some(Self::ACCOUNT),
"SUBACCOUNT" => ::core::option::Option::Some(Self::SUBACCOUNT),
"CONNECTION" => ::core::option::Option::Some(Self::CONNECTION),
"SERVICE" => ::core::option::Option::Some(Self::SERVICE),
"REGION" => ::core::option::Option::Some(Self::REGION),
"SYMBOL" => ::core::option::Option::Some(Self::SYMBOL),
"AUTH_SUBJECT" => ::core::option::Option::Some(Self::AUTH_SUBJECT),
_ => ::core::option::Option::None,
}
}
fn values() -> &'static [Self] {
&[
Self::SCOPE_UNSPECIFIED,
Self::CLIENT_IP,
Self::API_KEY,
Self::ACCOUNT,
Self::SUBACCOUNT,
Self::CONNECTION,
Self::SERVICE,
Self::REGION,
Self::SYMBOL,
Self::AUTH_SUBJECT,
]
}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(i32)]
pub enum RefillModel {
REFILL_UNSPECIFIED = 0i32,
CONTINUOUS = 1i32,
FIXED_WINDOW = 2i32,
ROLLING_WINDOW = 3i32,
}
impl RefillModel {
#[allow(non_upper_case_globals)]
pub const RefillUnspecified: Self = Self::REFILL_UNSPECIFIED;
#[allow(non_upper_case_globals)]
pub const Continuous: Self = Self::CONTINUOUS;
#[allow(non_upper_case_globals)]
pub const FixedWindow: Self = Self::FIXED_WINDOW;
#[allow(non_upper_case_globals)]
pub const RollingWindow: Self = Self::ROLLING_WINDOW;
}
impl ::core::default::Default for RefillModel {
fn default() -> Self {
Self::REFILL_UNSPECIFIED
}
}
impl ::serde::Serialize for RefillModel {
fn serialize<S: ::serde::Serializer>(
&self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
s.serialize_str(::buffa::Enumeration::proto_name(self))
}
}
impl<'de> ::serde::Deserialize<'de> for RefillModel {
fn deserialize<D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
struct _V;
impl ::serde::de::Visitor<'_> for _V {
type Value = RefillModel;
fn expecting(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.write_str(
concat!("a string, integer, or null for ", stringify!(RefillModel)),
)
}
fn visit_str<E: ::serde::de::Error>(
self,
v: &str,
) -> ::core::result::Result<RefillModel, E> {
<RefillModel as ::buffa::Enumeration>::from_proto_name(v)
.ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) })
}
fn visit_i64<E: ::serde::de::Error>(
self,
v: i64,
) -> ::core::result::Result<RefillModel, E> {
let v32 = i32::try_from(v)
.map_err(|_| {
::serde::de::Error::custom(
::buffa::alloc::format!("enum value {v} out of i32 range"),
)
})?;
<RefillModel as ::buffa::Enumeration>::from_i32(v32)
.ok_or_else(|| {
::serde::de::Error::custom(
::buffa::alloc::format!("unknown enum value {v32}"),
)
})
}
fn visit_u64<E: ::serde::de::Error>(
self,
v: u64,
) -> ::core::result::Result<RefillModel, E> {
let v32 = i32::try_from(v)
.map_err(|_| {
::serde::de::Error::custom(
::buffa::alloc::format!("enum value {v} out of i32 range"),
)
})?;
<RefillModel as ::buffa::Enumeration>::from_i32(v32)
.ok_or_else(|| {
::serde::de::Error::custom(
::buffa::alloc::format!("unknown enum value {v32}"),
)
})
}
fn visit_unit<E: ::serde::de::Error>(
self,
) -> ::core::result::Result<RefillModel, E> {
::core::result::Result::Ok(::core::default::Default::default())
}
}
d.deserialize_any(_V)
}
}
impl ::buffa::json_helpers::ProtoElemJson for RefillModel {
fn serialize_proto_json<S: ::serde::Serializer>(
v: &Self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
::serde::Serialize::serialize(v, s)
}
fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
<Self as ::serde::Deserialize>::deserialize(d)
}
}
impl ::buffa::Enumeration for RefillModel {
fn from_i32(value: i32) -> ::core::option::Option<Self> {
match value {
0i32 => ::core::option::Option::Some(Self::REFILL_UNSPECIFIED),
1i32 => ::core::option::Option::Some(Self::CONTINUOUS),
2i32 => ::core::option::Option::Some(Self::FIXED_WINDOW),
3i32 => ::core::option::Option::Some(Self::ROLLING_WINDOW),
_ => ::core::option::Option::None,
}
}
fn to_i32(&self) -> i32 {
*self as i32
}
fn proto_name(&self) -> &'static str {
match self {
Self::REFILL_UNSPECIFIED => "REFILL_UNSPECIFIED",
Self::CONTINUOUS => "CONTINUOUS",
Self::FIXED_WINDOW => "FIXED_WINDOW",
Self::ROLLING_WINDOW => "ROLLING_WINDOW",
}
}
fn from_proto_name(name: &str) -> ::core::option::Option<Self> {
match name {
"REFILL_UNSPECIFIED" => {
::core::option::Option::Some(Self::REFILL_UNSPECIFIED)
}
"CONTINUOUS" => ::core::option::Option::Some(Self::CONTINUOUS),
"FIXED_WINDOW" => ::core::option::Option::Some(Self::FIXED_WINDOW),
"ROLLING_WINDOW" => ::core::option::Option::Some(Self::ROLLING_WINDOW),
_ => ::core::option::Option::None,
}
}
fn values() -> &'static [Self] {
&[
Self::REFILL_UNSPECIFIED,
Self::CONTINUOUS,
Self::FIXED_WINDOW,
Self::ROLLING_WINDOW,
]
}
}
#[derive(Clone, PartialEq, Default)]
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[serde(default)]
pub struct RateLimitDetail {
#[serde(
rename = "reason",
with = "::buffa::json_helpers::proto_enum",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_default_enum_value"
)]
pub reason: ::buffa::EnumValue<FailureReason>,
#[serde(
rename = "limit",
with = "::buffa::json_helpers::opt_uint64",
skip_serializing_if = "::core::option::Option::is_none"
)]
pub limit: ::core::option::Option<u64>,
#[serde(
rename = "remaining",
with = "::buffa::json_helpers::opt_uint64",
skip_serializing_if = "::core::option::Option::is_none"
)]
pub remaining: ::core::option::Option<u64>,
#[serde(
rename = "retryAfterMs",
alias = "retry_after_ms",
with = "::buffa::json_helpers::opt_uint64",
skip_serializing_if = "::core::option::Option::is_none"
)]
pub retry_after_ms: ::core::option::Option<u64>,
#[serde(
rename = "policyVersion",
alias = "policy_version",
with = "::buffa::json_helpers::opt_uint64",
skip_serializing_if = "::core::option::Option::is_none"
)]
pub policy_version: ::core::option::Option<u64>,
#[serde(
rename = "operationId",
alias = "operation_id",
with = "::buffa::json_helpers::proto_string",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_str"
)]
pub operation_id: ::buffa::alloc::string::String,
#[serde(
rename = "policyClass",
alias = "policy_class",
with = "::buffa::json_helpers::proto_enum",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_default_enum_value"
)]
pub policy_class: ::buffa::EnumValue<PolicyClass>,
#[serde(
rename = "scope",
with = "::buffa::json_helpers::proto_enum",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_default_enum_value"
)]
pub scope: ::buffa::EnumValue<LimiterScope>,
#[serde(
rename = "refillModel",
alias = "refill_model",
with = "::buffa::json_helpers::proto_enum",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_default_enum_value"
)]
pub refill_model: ::buffa::EnumValue<RefillModel>,
#[serde(skip)]
#[doc(hidden)]
pub __buffa_unknown_fields: ::buffa::UnknownFields,
}
impl ::core::fmt::Debug for RateLimitDetail {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_struct("RateLimitDetail")
.field("reason", &self.reason)
.field("limit", &self.limit)
.field("remaining", &self.remaining)
.field("retry_after_ms", &self.retry_after_ms)
.field("policy_version", &self.policy_version)
.field("operation_id", &self.operation_id)
.field("policy_class", &self.policy_class)
.field("scope", &self.scope)
.field("refill_model", &self.refill_model)
.finish()
}
}
impl RateLimitDetail {
pub const TYPE_URL: &'static str = "type.googleapis.com/polyester.ratelimit.v1.RateLimitDetail";
}
impl RateLimitDetail {
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_limit(mut self, value: u64) -> Self {
self.limit = Some(value);
self
}
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_remaining(mut self, value: u64) -> Self {
self.remaining = Some(value);
self
}
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_retry_after_ms(mut self, value: u64) -> Self {
self.retry_after_ms = Some(value);
self
}
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_policy_version(mut self, value: u64) -> Self {
self.policy_version = Some(value);
self
}
}
::buffa::impl_default_instance!(RateLimitDetail);
impl ::buffa::MessageName for RateLimitDetail {
const PACKAGE: &'static str = "polyester.ratelimit.v1";
const NAME: &'static str = "RateLimitDetail";
const FULL_NAME: &'static str = "polyester.ratelimit.v1.RateLimitDetail";
const TYPE_URL: &'static str = "type.googleapis.com/polyester.ratelimit.v1.RateLimitDetail";
}
impl ::buffa::Message for RateLimitDetail {
#[allow(clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u32;
{
let val = self.reason.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32;
}
}
if let Some(v) = self.limit {
size += 1u32 + ::buffa::types::uint64_encoded_len(v) as u32;
}
if let Some(v) = self.remaining {
size += 1u32 + ::buffa::types::uint64_encoded_len(v) as u32;
}
if let Some(v) = self.retry_after_ms {
size += 1u32 + ::buffa::types::uint64_encoded_len(v) as u32;
}
if let Some(v) = self.policy_version {
size += 1u32 + ::buffa::types::uint64_encoded_len(v) as u32;
}
if !self.operation_id.is_empty() {
size += 1u32 + ::buffa::types::string_encoded_len(&self.operation_id) as u32;
}
{
let val = self.policy_class.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32;
}
}
{
let val = self.scope.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32;
}
}
{
let val = self.refill_model.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32;
}
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
{
let val = self.reason.to_i32();
if val != 0 {
::buffa::types::put_int32_field(1u32, val, buf);
}
}
if let Some(v) = self.limit {
::buffa::types::put_uint64_field(2u32, v, buf);
}
if let Some(v) = self.remaining {
::buffa::types::put_uint64_field(3u32, v, buf);
}
if let Some(v) = self.retry_after_ms {
::buffa::types::put_uint64_field(4u32, v, buf);
}
if let Some(v) = self.policy_version {
::buffa::types::put_uint64_field(5u32, v, buf);
}
if !self.operation_id.is_empty() {
::buffa::types::put_string_field(6u32, &self.operation_id, buf);
}
{
let val = self.policy_class.to_i32();
if val != 0 {
::buffa::types::put_int32_field(7u32, val, buf);
}
}
{
let val = self.scope.to_i32();
if val != 0 {
::buffa::types::put_int32_field(8u32, val, buf);
}
}
{
let val = self.refill_model.to_i32();
if val != 0 {
::buffa::types::put_int32_field(9u32, val, buf);
}
}
self.__buffa_unknown_fields.write_to(buf);
}
fn merge_field(
&mut self,
tag: ::buffa::encoding::Tag,
buf: &mut impl ::buffa::bytes::Buf,
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::bytes::Buf as _;
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
self.reason = ::buffa::EnumValue::from(
::buffa::types::decode_int32(buf)?,
);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
self.limit = ::core::option::Option::Some(
::buffa::types::decode_uint64(buf)?,
);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
self.remaining = ::core::option::Option::Some(
::buffa::types::decode_uint64(buf)?,
);
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
self.retry_after_ms = ::core::option::Option::Some(
::buffa::types::decode_uint64(buf)?,
);
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
self.policy_version = ::core::option::Option::Some(
::buffa::types::decode_uint64(buf)?,
);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
::buffa::types::merge_string(&mut self.operation_id, buf)?;
}
7u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
self.policy_class = ::buffa::EnumValue::from(
::buffa::types::decode_int32(buf)?,
);
}
8u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
self.scope = ::buffa::EnumValue::from(
::buffa::types::decode_int32(buf)?,
);
}
9u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
self.refill_model = ::buffa::EnumValue::from(
::buffa::types::decode_int32(buf)?,
);
}
_ => {
self.__buffa_unknown_fields
.push(::buffa::encoding::decode_unknown_field(tag, buf, ctx)?);
}
}
::core::result::Result::Ok(())
}
fn clear(&mut self) {
self.reason = ::buffa::EnumValue::from(0);
self.limit = ::core::option::Option::None;
self.remaining = ::core::option::Option::None;
self.retry_after_ms = ::core::option::Option::None;
self.policy_version = ::core::option::Option::None;
self.operation_id.clear();
self.policy_class = ::buffa::EnumValue::from(0);
self.scope = ::buffa::EnumValue::from(0);
self.refill_model = ::buffa::EnumValue::from(0);
self.__buffa_unknown_fields.clear();
}
}
impl ::buffa::ExtensionSet for RateLimitDetail {
const PROTO_FQN: &'static str = "polyester.ratelimit.v1.RateLimitDetail";
fn unknown_fields(&self) -> &::buffa::UnknownFields {
&self.__buffa_unknown_fields
}
fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
&mut self.__buffa_unknown_fields
}
}
impl ::buffa::json_helpers::ProtoElemJson for RateLimitDetail {
fn serialize_proto_json<S: ::serde::Serializer>(
v: &Self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
::serde::Serialize::serialize(v, s)
}
fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
<Self as ::serde::Deserialize>::deserialize(d)
}
}
#[doc(hidden)]
pub const __RATE_LIMIT_DETAIL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
type_url: "type.googleapis.com/polyester.ratelimit.v1.RateLimitDetail",
to_json: ::buffa::type_registry::any_to_json::<RateLimitDetail>,
from_json: ::buffa::type_registry::any_from_json::<RateLimitDetail>,
is_wkt: false,
};
#[allow(
non_camel_case_types,
dead_code,
unused_imports,
unused_qualifications,
clippy::derivable_impls,
clippy::match_single_binding,
clippy::uninlined_format_args,
clippy::doc_lazy_continuation,
clippy::module_inception
)]
pub mod __buffa {
#[allow(unused_imports)]
use super::*;
pub mod view {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, Default)]
pub struct RateLimitDetailView<'a> {
pub reason: ::buffa::EnumValue<super::super::FailureReason>,
pub limit: ::core::option::Option<u64>,
pub remaining: ::core::option::Option<u64>,
pub retry_after_ms: ::core::option::Option<u64>,
pub policy_version: ::core::option::Option<u64>,
pub operation_id: &'a str,
pub policy_class: ::buffa::EnumValue<super::super::PolicyClass>,
pub scope: ::buffa::EnumValue<super::super::LimiterScope>,
pub refill_model: ::buffa::EnumValue<super::super::RefillModel>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for RateLimitDetailView<'a> {
type Owned = super::super::RateLimitDetail;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(
::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT,
);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.reason = ::buffa::EnumValue::from(
::buffa::types::decode_int32(&mut cur)?,
);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.limit = Some(::buffa::types::decode_uint64(&mut cur)?);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.remaining = Some(::buffa::types::decode_uint64(&mut cur)?);
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.retry_after_ms = Some(
::buffa::types::decode_uint64(&mut cur)?,
);
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.policy_version = Some(
::buffa::types::decode_uint64(&mut cur)?,
);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.operation_id = ::buffa::types::borrow_str(&mut cur)?;
}
7u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.policy_class = ::buffa::EnumValue::from(
::buffa::types::decode_int32(&mut cur)?,
);
}
8u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.scope = ::buffa::EnumValue::from(
::buffa::types::decode_int32(&mut cur)?,
);
}
9u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.refill_model = ::buffa::EnumValue::from(
::buffa::types::decode_int32(&mut cur)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::RateLimitDetail,
::buffa::DecodeError,
> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<
super::super::RateLimitDetail,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::RateLimitDetail {
reason: self.reason,
limit: self.limit,
remaining: self.remaining,
retry_after_ms: self.retry_after_ms,
policy_version: self.policy_version,
operation_id: self.operation_id.to_string(),
policy_class: self.policy_class,
scope: self.scope,
refill_model: self.refill_model,
__buffa_unknown_fields: self
.__buffa_unknown_fields
.to_owned()?
.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for RateLimitDetailView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u32;
{
let val = self.reason.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32;
}
}
if let Some(v) = self.limit {
size += 1u32 + ::buffa::types::uint64_encoded_len(v) as u32;
}
if let Some(v) = self.remaining {
size += 1u32 + ::buffa::types::uint64_encoded_len(v) as u32;
}
if let Some(v) = self.retry_after_ms {
size += 1u32 + ::buffa::types::uint64_encoded_len(v) as u32;
}
if let Some(v) = self.policy_version {
size += 1u32 + ::buffa::types::uint64_encoded_len(v) as u32;
}
if !self.operation_id.is_empty() {
size
+= 1u32
+ ::buffa::types::string_encoded_len(&self.operation_id)
as u32;
}
{
let val = self.policy_class.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32;
}
}
{
let val = self.scope.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32;
}
}
{
let val = self.refill_model.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32;
}
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
{
let val = self.reason.to_i32();
if val != 0 {
::buffa::types::put_int32_field(1u32, val, buf);
}
}
if let Some(v) = self.limit {
::buffa::types::put_uint64_field(2u32, v, buf);
}
if let Some(v) = self.remaining {
::buffa::types::put_uint64_field(3u32, v, buf);
}
if let Some(v) = self.retry_after_ms {
::buffa::types::put_uint64_field(4u32, v, buf);
}
if let Some(v) = self.policy_version {
::buffa::types::put_uint64_field(5u32, v, buf);
}
if !self.operation_id.is_empty() {
::buffa::types::put_string_field(6u32, &self.operation_id, buf);
}
{
let val = self.policy_class.to_i32();
if val != 0 {
::buffa::types::put_int32_field(7u32, val, buf);
}
}
{
let val = self.scope.to_i32();
if val != 0 {
::buffa::types::put_int32_field(8u32, val, buf);
}
}
{
let val = self.refill_model.to_i32();
if val != 0 {
::buffa::types::put_int32_field(9u32, val, buf);
}
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'__a> ::serde::Serialize for RateLimitDetailView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !::buffa::json_helpers::skip_if::is_default_enum_value(&self.reason) {
__map.serialize_entry("reason", &self.reason)?;
}
if let ::core::option::Option::Some(__v) = self.limit {
__map
.serialize_entry(
"limit",
&::buffa::json_helpers::ProtoJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.remaining {
__map
.serialize_entry(
"remaining",
&::buffa::json_helpers::ProtoJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.retry_after_ms {
__map
.serialize_entry(
"retryAfterMs",
&::buffa::json_helpers::ProtoJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.policy_version {
__map
.serialize_entry(
"policyVersion",
&::buffa::json_helpers::ProtoJson(&__v),
)?;
}
if !::buffa::json_helpers::skip_if::is_empty_str(self.operation_id) {
__map.serialize_entry("operationId", self.operation_id)?;
}
if !::buffa::json_helpers::skip_if::is_default_enum_value(
&self.policy_class,
) {
__map.serialize_entry("policyClass", &self.policy_class)?;
}
if !::buffa::json_helpers::skip_if::is_default_enum_value(&self.scope) {
__map.serialize_entry("scope", &self.scope)?;
}
if !::buffa::json_helpers::skip_if::is_default_enum_value(
&self.refill_model,
) {
__map.serialize_entry("refillModel", &self.refill_model)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for RateLimitDetailView<'a> {
const PACKAGE: &'static str = "polyester.ratelimit.v1";
const NAME: &'static str = "RateLimitDetail";
const FULL_NAME: &'static str = "polyester.ratelimit.v1.RateLimitDetail";
const TYPE_URL: &'static str = "type.googleapis.com/polyester.ratelimit.v1.RateLimitDetail";
}
::buffa::impl_default_view_instance!(RateLimitDetailView);
::buffa::impl_view_reborrow!(RateLimitDetailView);
#[derive(Clone, Debug)]
pub struct RateLimitDetailOwnedView(
::buffa::OwnedView<RateLimitDetailView<'static>>,
);
impl RateLimitDetailOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
RateLimitDetailOwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
RateLimitDetailOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::RateLimitDetail,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
RateLimitDetailOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &RateLimitDetailView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::RateLimitDetail,
::buffa::DecodeError,
> {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn reason(&self) -> ::buffa::EnumValue<super::super::FailureReason> {
self.0.reborrow().reason
}
#[must_use]
pub fn limit(&self) -> ::core::option::Option<u64> {
self.0.reborrow().limit
}
#[must_use]
pub fn remaining(&self) -> ::core::option::Option<u64> {
self.0.reborrow().remaining
}
#[must_use]
pub fn retry_after_ms(&self) -> ::core::option::Option<u64> {
self.0.reborrow().retry_after_ms
}
#[must_use]
pub fn policy_version(&self) -> ::core::option::Option<u64> {
self.0.reborrow().policy_version
}
#[must_use]
pub fn operation_id(&self) -> &'_ str {
self.0.reborrow().operation_id
}
#[must_use]
pub fn policy_class(&self) -> ::buffa::EnumValue<super::super::PolicyClass> {
self.0.reborrow().policy_class
}
#[must_use]
pub fn scope(&self) -> ::buffa::EnumValue<super::super::LimiterScope> {
self.0.reborrow().scope
}
#[must_use]
pub fn refill_model(&self) -> ::buffa::EnumValue<super::super::RefillModel> {
self.0.reborrow().refill_model
}
}
impl ::core::convert::From<::buffa::OwnedView<RateLimitDetailView<'static>>>
for RateLimitDetailOwnedView {
fn from(inner: ::buffa::OwnedView<RateLimitDetailView<'static>>) -> Self {
RateLimitDetailOwnedView(inner)
}
}
impl ::core::convert::From<RateLimitDetailOwnedView>
for ::buffa::OwnedView<RateLimitDetailView<'static>> {
fn from(wrapper: RateLimitDetailOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<RateLimitDetailView<'static>>>
for RateLimitDetailOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<RateLimitDetailView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::RateLimitDetail {
type View<'a> = RateLimitDetailView<'a>;
type ViewHandle = RateLimitDetailOwnedView;
}
impl ::serde::Serialize for RateLimitDetailOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
}
pub fn register_types(reg: &mut ::buffa::type_registry::TypeRegistry) {
reg.register_json_any(super::__RATE_LIMIT_DETAIL_JSON_ANY);
}
}
#[doc(inline)]
pub use self::__buffa::view::RateLimitDetailView;
#[doc(inline)]
pub use self::__buffa::view::RateLimitDetailOwnedView;
#[doc(inline)]
pub use self::__buffa::register_types;