Skip to main content

cc_lb_plugin_wire/v2/
sign.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, vec::Vec};
6use serde::{Deserialize, Serialize};
7
8use crate::v2::common::{HeaderWire, ShapedRequestWire};
9use crate::wire_function::{FallbackPolicy, WireFunction};
10
11#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
12#[serde(deny_unknown_fields)]
13pub struct SignRequest {
14    pub shaped: ShapedRequestWire,
15    pub signer_state: serde_json::Value,
16}
17
18impl SignRequest {
19    pub fn dry_run_sample() -> Self {
20        Self {
21            shaped: ShapedRequestWire::dry_run_sample(),
22            signer_state: serde_json::Value::Null,
23        }
24    }
25}
26
27#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
28#[serde(deny_unknown_fields)]
29pub struct SignResponse {
30    pub url: Option<String>,
31    pub method: Option<String>,
32    pub headers: Option<Vec<HeaderWire>>,
33    pub body_base64: Option<String>,
34}
35
36impl SignResponse {
37    pub fn dry_run_sample() -> Self {
38        Self {
39            url: None,
40            method: None,
41            headers: None,
42            body_base64: None,
43        }
44    }
45}
46
47pub struct SignFn;
48
49impl WireFunction for SignFn {
50    const NAME: &'static str = "sign";
51    const FALLBACK: FallbackPolicy = FallbackPolicy::FailRequest;
52    const SUPPORTED_VERSIONS: &'static [u32] = &[1];
53
54    type Request = SignRequest;
55    type Response = SignResponse;
56
57    fn dry_run_request() -> Self::Request {
58        SignRequest::dry_run_sample()
59    }
60
61    fn dry_run_response() -> Self::Response {
62        SignResponse::dry_run_sample()
63    }
64}