Skip to main content

cc_lb_plugin_wire/v2/
build_signer.rs

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