Skip to main content

cc_lb_plugin_wire/v1/
sign.rs

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