pulumi_gestalt_rust_adapter/
lib.rs

1use serde::Serialize;
2use serde::de::DeserializeOwned;
3
4pub trait GestaltContext {
5    type Output<T>;
6    type CompositeOutput;
7
8    fn new_output<T: Serialize>(&self, value: &T) -> Self::Output<T>;
9    fn new_secret<T: Serialize>(&self, value: &T) -> Self::Output<T>;
10    fn register_resource(
11        &self,
12        request: RegisterResourceRequest<Self::Output<()>>,
13    ) -> Self::CompositeOutput;
14    fn invoke_resource(
15        &self,
16        request: InvokeResourceRequest<Self::Output<()>>,
17    ) -> Self::CompositeOutput;
18
19    fn get_config(
20        &self,
21        name: Option<&str>,
22        key: &str,
23    ) -> Option<ConfigValue<Self::Output<String>>>;
24}
25
26pub trait GestaltOutput<T>: Clone {
27    type Me<A>;
28
29    fn map<B, F>(&self, f: F) -> Self::Me<B>
30    where
31        F: Fn(T) -> B + Send + 'static,
32        T: DeserializeOwned,
33        B: Serialize;
34
35    fn add_to_export(&self, key: &str);
36
37    /// Should not be used directly. Use `pulumi_gestalt_rust::pulumi_combine!` instead
38    fn combine<RESULT>(&self, others: &[&Self::Me<()>]) -> Self::Me<RESULT>;
39
40    /// Forcefully changes the visible type of underlying Output
41    ///
42    /// Can be used to work around Pulumi provider incorrect types
43    ///
44    /// MUST NOT change the underlying value - only the projected type
45    ///
46    /// # Safety
47    ///
48    /// The underlying output must be of type `F`.
49    unsafe fn transmute<F>(self) -> Self::Me<F>;
50
51    #[doc(hidden)]
52    fn drop_type(self) -> Self::Me<()> {
53        unsafe { self.transmute::<()>() }
54    }
55}
56
57pub trait GestaltCompositeOutput {
58    type Output<T>;
59
60    fn get_field<T>(&self, key: &str) -> Self::Output<T>;
61}
62
63pub struct RegisterResourceRequest<'a, OUTPUT> {
64    pub type_: String,
65    pub name: String,
66    pub version: String,
67    pub object: &'a [ResourceRequestObjectField<'a, OUTPUT>],
68}
69
70pub struct InvokeResourceRequest<'a, OUTPUT> {
71    pub token: String,
72    pub version: String,
73    pub object: &'a [ResourceRequestObjectField<'a, OUTPUT>],
74}
75
76pub struct ResourceRequestObjectField<'a, OUTPUT> {
77    pub name: String,
78    pub value: &'a OUTPUT,
79}
80
81pub enum ConfigValue<OUTPUT> {
82    PlainText(String),
83    Secret(OUTPUT),
84}