bitwarden_test/play/
scene_template.rs

1//! SceneTemplate trait for defining test scenes
2
3use std::collections::HashMap;
4
5use serde::{Serialize, de::DeserializeOwned};
6
7/// Trait for defining scene templates
8///
9/// Scene templates define how to create and tear down test data.
10/// Each template has associated types for input arguments and output results.
11pub trait SceneTemplate {
12    /// The type of arguments passed to create the scene
13    type Arguments: Serialize + Clone + Send + Sync;
14
15    /// The type of result returned when the scene is created
16    type Result: DeserializeOwned + Send + Sync;
17
18    /// The name of this template (used in API calls)
19    fn template_name() -> &'static str;
20}
21
22/// Request body for creating a scene
23#[derive(Serialize)]
24pub(crate) struct CreateSceneRequest<'a, A: Serialize> {
25    pub template: &'a str,
26    pub arguments: &'a A,
27}
28
29/// Response from creating a scene
30#[derive(serde::Deserialize)]
31pub(crate) struct CreateSceneResponse<R> {
32    pub result: R,
33    #[serde(rename = "mangleMap", default)]
34    pub mangle_map: HashMap<String, String>,
35}