Skip to main content

cc_lb_plugin_wire/v2/
normalize_error.rs

1//! v2 is a fork of v1 to allow additive cache-related fields. v1 is FROZEN.
2
3extern crate alloc;
4
5use alloc::string::String;
6use serde::{Deserialize, Serialize};
7
8use crate::wire_function::{FallbackPolicy, WireFunction};
9
10#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
11#[serde(deny_unknown_fields)]
12pub struct NormalizeErrorRequest {
13    pub status: u16,
14    pub body_base64: String,
15}
16
17impl NormalizeErrorRequest {
18    pub fn dry_run_sample() -> Self {
19        Self {
20            status: 500,
21            body_base64: String::new(),
22        }
23    }
24}
25
26#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
27#[serde(deny_unknown_fields)]
28pub struct NormalizeErrorResponse {
29    pub body_base64: Option<String>,
30}
31
32impl NormalizeErrorResponse {
33    pub fn dry_run_sample() -> Self {
34        Self { body_base64: None }
35    }
36}
37
38pub struct NormalizeErrorFn;
39
40impl WireFunction for NormalizeErrorFn {
41    const NAME: &'static str = "normalize_error";
42    const FALLBACK: FallbackPolicy = FallbackPolicy::PassThrough;
43    const SUPPORTED_VERSIONS: &'static [u32] = &[1];
44
45    type Request = NormalizeErrorRequest;
46    type Response = NormalizeErrorResponse;
47
48    fn dry_run_request() -> Self::Request {
49        NormalizeErrorRequest::dry_run_sample()
50    }
51
52    fn dry_run_response() -> Self::Response {
53        NormalizeErrorResponse::dry_run_sample()
54    }
55}