#[cfg(feature = "rpc")]
include!("./google.rpc.rs");
#[cfg(feature = "rpc")]
macro_rules! has_impl {
($name:ident) => {
paste::paste! {
#[doc = "Returns true if the `" $name "` matches the given value."]
#[inline]
pub fn [< has_ $name >](&self, $name: &str) -> bool {
self.$name == $name
}
}
};
($name:ident, $name_override:ident) => {
paste::paste! {
#[doc = "Returns true if the `" $name "` matches the given value."]
#[inline]
pub fn [< has_ $name >](&self, $name_override: &str) -> bool {
self.$name_override == $name_override
}
}
};
}
#[cfg(all(feature = "serde", feature = "rpc"))]
mod rpc_serde_impls;
#[cfg(feature = "rpc")]
mod error_details;
#[cfg(feature = "rpc")]
mod http;
#[cfg(all(feature = "cel", feature = "rpc"))]
mod rpc_cel_impls;
#[derive(Clone, PartialEq, Eq, ::prost::Message)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Status {
#[prost(int32, tag = "1")]
pub code: i32,
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "3")]
pub details: ::prost::alloc::vec::Vec<crate::protobuf::Any>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Code {
Ok = 0,
Cancelled = 1,
Unknown = 2,
InvalidArgument = 3,
DeadlineExceeded = 4,
NotFound = 5,
AlreadyExists = 6,
PermissionDenied = 7,
Unauthenticated = 16,
ResourceExhausted = 8,
FailedPrecondition = 9,
Aborted = 10,
OutOfRange = 11,
Unimplemented = 12,
Internal = 13,
Unavailable = 14,
DataLoss = 15,
}
impl Code {
#[must_use]
#[inline]
pub const fn as_str_name(&self) -> &'static str {
match self {
Self::Ok => "OK",
Self::Cancelled => "CANCELLED",
Self::Unknown => "UNKNOWN",
Self::InvalidArgument => "INVALID_ARGUMENT",
Self::DeadlineExceeded => "DEADLINE_EXCEEDED",
Self::NotFound => "NOT_FOUND",
Self::AlreadyExists => "ALREADY_EXISTS",
Self::PermissionDenied => "PERMISSION_DENIED",
Self::Unauthenticated => "UNAUTHENTICATED",
Self::ResourceExhausted => "RESOURCE_EXHAUSTED",
Self::FailedPrecondition => "FAILED_PRECONDITION",
Self::Aborted => "ABORTED",
Self::OutOfRange => "OUT_OF_RANGE",
Self::Unimplemented => "UNIMPLEMENTED",
Self::Internal => "INTERNAL",
Self::Unavailable => "UNAVAILABLE",
Self::DataLoss => "DATA_LOSS",
}
}
#[must_use]
#[inline]
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"OK" => Some(Self::Ok),
"CANCELLED" => Some(Self::Cancelled),
"UNKNOWN" => Some(Self::Unknown),
"INVALID_ARGUMENT" => Some(Self::InvalidArgument),
"DEADLINE_EXCEEDED" => Some(Self::DeadlineExceeded),
"NOT_FOUND" => Some(Self::NotFound),
"ALREADY_EXISTS" => Some(Self::AlreadyExists),
"PERMISSION_DENIED" => Some(Self::PermissionDenied),
"UNAUTHENTICATED" => Some(Self::Unauthenticated),
"RESOURCE_EXHAUSTED" => Some(Self::ResourceExhausted),
"FAILED_PRECONDITION" => Some(Self::FailedPrecondition),
"ABORTED" => Some(Self::Aborted),
"OUT_OF_RANGE" => Some(Self::OutOfRange),
"UNIMPLEMENTED" => Some(Self::Unimplemented),
"INTERNAL" => Some(Self::Internal),
"UNAVAILABLE" => Some(Self::Unavailable),
"DATA_LOSS" => Some(Self::DataLoss),
_ => None,
}
}
}
#[cfg(feature = "cel")]
impl From<Status> for cel::Value {
fn from(value: Status) -> Self {
let mut cel_map: std::collections::HashMap<cel::objects::Key, Self> =
std::collections::HashMap::new();
cel_map.insert("code".into(), Self::Int(value.code.into()));
cel_map.insert("message".into(), Self::String(value.message.into()));
cel_map.insert("details".into(), value.details.into());
Self::Map(cel_map.into())
}
}