use serde::Serialize;
#[derive(Debug, Clone, Serialize)]
pub struct FieldViolationV1 {
pub field: String,
pub description: String,
pub reason: String,
}
impl FieldViolationV1 {
#[must_use]
pub fn new(
field: impl Into<String>,
description: impl Into<String>,
reason: impl Into<String>,
) -> Self {
Self {
field: field.into(),
description: description.into(),
reason: reason.into(),
}
}
}
pub type FieldViolation = FieldViolationV1;
#[derive(Debug, Clone, Serialize)]
pub struct QuotaViolationV1 {
pub subject: String,
pub description: String,
}
impl QuotaViolationV1 {
#[must_use]
pub fn new(subject: impl Into<String>, description: impl Into<String>) -> Self {
Self {
subject: subject.into(),
description: description.into(),
}
}
}
pub type QuotaViolation = QuotaViolationV1;
#[derive(Debug, Clone, Serialize)]
pub struct PreconditionViolationV1 {
#[serde(rename = "type")]
pub type_: String,
pub subject: String,
pub description: String,
}
impl PreconditionViolationV1 {
#[must_use]
pub fn new(
type_: impl Into<String>,
subject: impl Into<String>,
description: impl Into<String>,
) -> Self {
Self {
type_: type_.into(),
subject: subject.into(),
description: description.into(),
}
}
}
pub type PreconditionViolation = PreconditionViolationV1;
#[derive(Debug, Clone, Serialize)]
#[allow(clippy::empty_structs_with_brackets)]
pub struct CancelledV1 {}
impl CancelledV1 {
#[must_use]
pub fn new() -> Self {
Self {}
}
}
impl Default for CancelledV1 {
fn default() -> Self {
Self::new()
}
}
pub type Cancelled = CancelledV1;
#[derive(Debug, Clone, Serialize)]
pub struct UnknownV1 {
#[serde(skip)]
pub description: String,
}
impl UnknownV1 {
#[must_use]
pub fn new(description: impl Into<String>) -> Self {
Self {
description: description.into(),
}
}
}
pub type Unknown = UnknownV1;
#[derive(Debug, Clone, Serialize)]
#[serde(untagged)]
pub enum InvalidArgumentV1 {
FieldViolations {
field_violations: Vec<FieldViolation>,
},
Format {
format: String,
},
Constraint {
constraint: String,
},
}
impl InvalidArgumentV1 {
#[must_use]
pub fn fields(violations: impl Into<Vec<FieldViolation>>) -> Self {
Self::FieldViolations {
field_violations: violations.into(),
}
}
#[must_use]
pub fn format(msg: impl Into<String>) -> Self {
Self::Format { format: msg.into() }
}
#[must_use]
pub fn constraint(msg: impl Into<String>) -> Self {
Self::Constraint {
constraint: msg.into(),
}
}
}
pub type InvalidArgument = InvalidArgumentV1;
#[derive(Debug, Clone, Serialize)]
#[allow(clippy::empty_structs_with_brackets)]
pub struct DeadlineExceededV1 {}
impl DeadlineExceededV1 {
#[must_use]
pub fn new() -> Self {
Self {}
}
}
impl Default for DeadlineExceededV1 {
fn default() -> Self {
Self::new()
}
}
pub type DeadlineExceeded = DeadlineExceededV1;
#[derive(Debug, Clone, Serialize)]
#[allow(clippy::empty_structs_with_brackets)]
pub struct NotFoundV1 {}
impl NotFoundV1 {
#[must_use]
pub fn new() -> Self {
Self {}
}
}
impl Default for NotFoundV1 {
fn default() -> Self {
Self::new()
}
}
pub type NotFound = NotFoundV1;
#[derive(Debug, Clone, Serialize)]
#[allow(clippy::empty_structs_with_brackets)]
pub struct AlreadyExistsV1 {}
impl AlreadyExistsV1 {
#[must_use]
pub fn new() -> Self {
Self {}
}
}
impl Default for AlreadyExistsV1 {
fn default() -> Self {
Self::new()
}
}
pub type AlreadyExists = AlreadyExistsV1;
#[derive(Debug, Clone, Serialize)]
pub struct PermissionDeniedV1 {
pub reason: String,
}
impl PermissionDeniedV1 {
#[must_use]
pub fn new(reason: impl Into<String>) -> Self {
Self {
reason: reason.into(),
}
}
}
pub type PermissionDenied = PermissionDeniedV1;
#[derive(Debug, Clone, Serialize)]
pub struct ResourceExhaustedV1 {
pub violations: Vec<QuotaViolation>,
}
impl ResourceExhaustedV1 {
#[must_use]
pub fn new(violations: impl Into<Vec<QuotaViolation>>) -> Self {
Self {
violations: violations.into(),
}
}
}
pub type ResourceExhausted = ResourceExhaustedV1;
#[derive(Debug, Clone, Serialize)]
pub struct FailedPreconditionV1 {
pub violations: Vec<PreconditionViolation>,
}
impl FailedPreconditionV1 {
#[must_use]
pub fn new(violations: impl Into<Vec<PreconditionViolation>>) -> Self {
Self {
violations: violations.into(),
}
}
}
pub type FailedPrecondition = FailedPreconditionV1;
#[derive(Debug, Clone, Serialize)]
pub struct AbortedV1 {
pub reason: String,
}
impl AbortedV1 {
#[must_use]
pub fn new(reason: impl Into<String>) -> Self {
Self {
reason: reason.into(),
}
}
}
pub type Aborted = AbortedV1;
#[derive(Debug, Clone, Serialize)]
pub struct OutOfRangeV1 {
pub field_violations: Vec<FieldViolation>,
}
impl OutOfRangeV1 {
#[must_use]
pub fn new(violations: impl Into<Vec<FieldViolation>>) -> Self {
Self {
field_violations: violations.into(),
}
}
}
pub type OutOfRange = OutOfRangeV1;
#[derive(Debug, Clone, Serialize)]
#[allow(clippy::empty_structs_with_brackets)]
pub struct UnimplementedV1 {}
impl UnimplementedV1 {
#[must_use]
pub fn new() -> Self {
Self {}
}
}
impl Default for UnimplementedV1 {
fn default() -> Self {
Self::new()
}
}
pub type Unimplemented = UnimplementedV1;
#[derive(Debug, Clone, Serialize)]
pub struct InternalV1 {
#[serde(skip)]
pub description: String,
}
impl InternalV1 {
#[must_use]
pub fn new(description: impl Into<String>) -> Self {
Self {
description: description.into(),
}
}
}
pub type Internal = InternalV1;
#[derive(Debug, Clone, Serialize)]
pub struct ServiceUnavailableV1 {
#[serde(skip_serializing_if = "Option::is_none")]
pub retry_after_seconds: Option<u64>,
}
impl ServiceUnavailableV1 {
#[must_use]
pub fn new(retry_after_seconds: Option<u64>) -> Self {
Self {
retry_after_seconds,
}
}
}
pub type ServiceUnavailable = ServiceUnavailableV1;
#[derive(Debug, Clone, Serialize)]
#[allow(clippy::empty_structs_with_brackets)]
pub struct DataLossV1 {}
impl DataLossV1 {
#[must_use]
pub fn new() -> Self {
Self {}
}
}
impl Default for DataLossV1 {
fn default() -> Self {
Self::new()
}
}
pub type DataLoss = DataLossV1;
#[derive(Debug, Clone, Serialize)]
pub struct UnauthenticatedV1 {
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
}
impl UnauthenticatedV1 {
#[must_use]
pub fn new() -> Self {
Self { reason: None }
}
#[must_use]
pub fn with_reason(mut self, reason: impl Into<String>) -> Self {
self.reason = Some(reason.into());
self
}
}
impl Default for UnauthenticatedV1 {
fn default() -> Self {
Self::new()
}
}
pub type Unauthenticated = UnauthenticatedV1;