Skip to main content

cc_lb_plugin_wire/v1/
build_signer.rs

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