Skip to content

Commit

Permalink
Save
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejressel committed Mar 5, 2024
1 parent 5e0d067 commit 0b6e146
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 50 deletions.
14 changes: 12 additions & 2 deletions pulumi_rust_wasm/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ pub struct Output<T> {
future: output_interface::Output,
// pulumi: Rc<Pulumi>,
}
//
// impl <T: serde::Serialize> Into<Output<T>> for (T,) {
// fn into(self) -> Output<T> {
// Output::new(&self)
// }
// }


impl <T: serde::Serialize> From<T> for Output<T> {
fn from(value: T) -> Output<T> {
Output::new(&value)
}
}

impl<T> Output<T> {

pub fn get_inner(&self) -> &output_interface::Output {
pub unsafe fn get_inner(&self) -> &output_interface::Output {
&self.future
}

Expand Down
15 changes: 6 additions & 9 deletions pulumi_wasm_main/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ pub mod component {
pub type Output = super::super::super::component::pulumi_wasm::output_interface::Output;
pub struct RandomStringArgs<'a,> {
pub name: wit_bindgen::rt::string::String,
pub length: Result<u32,&'a Output>,
pub length: &'a Output,
}
impl<'a,> ::core::fmt::Debug for RandomStringArgs<'a,> {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
Expand All @@ -246,20 +246,17 @@ pub mod component {
let vec1 = name0;
let ptr1 = vec1.as_ptr() as i32;
let len1 = vec1.len() as i32;
let (result2_0,result2_1,) = match length0 {
Ok(e) => { (0i32, wit_bindgen::rt::as_i32(e)) },
Err(e) => { (1i32, (e).handle() as i32) },
};

#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "component:pulumi-wasm/[email protected]")]
extern "C" {
#[link_name = "create-random-string"]
fn wit_import(_: i32, _: i32, _: i32, _: i32, );
fn wit_import(_: i32, _: i32, _: i32, );
}

#[cfg(not(target_arch = "wasm32"))]
fn wit_import(_: i32, _: i32, _: i32, _: i32, ){ unreachable!() }
wit_import(ptr1, len1, result2_0, result2_1);
fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() }
wit_import(ptr1, len1, (length0).handle() as i32);
}
}
#[allow(unused_unsafe, clippy::all)]
Expand Down Expand Up @@ -336,7 +333,7 @@ pub mod exports {
#[cfg(target_arch = "wasm32")]
#[link_section = "component-type:new-main"]
#[doc(hidden)]
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 803] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 165, 5, 1, 65, 2, 1, 65, 7, 1, 66, 17, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 2, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 100, 117, 112, 108, 105, 99, 97, 116, 101, 1, 8, 1, 111, 2, 115, 4, 1, 112, 9, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 10, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 11, 3, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 0, 2, 3, 0, 0, 6, 111, 117, 116, 112, 117, 116, 1, 66, 17, 2, 3, 2, 1, 1, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 107, 121, 1, 104, 1, 1, 107, 3, 1, 113, 2, 7, 108, 105, 116, 101, 114, 97, 108, 1, 2, 0, 3, 114, 101, 115, 1, 4, 0, 4, 0, 10, 101, 105, 116, 104, 101, 114, 45, 117, 51, 50, 3, 0, 5, 1, 106, 1, 121, 1, 3, 1, 114, 2, 4, 110, 97, 109, 101, 115, 6, 108, 101, 110, 103, 116, 104, 7, 4, 0, 18, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 97, 114, 103, 115, 3, 0, 8, 1, 105, 1, 1, 114, 2, 3, 117, 114, 108, 10, 6, 114, 101, 115, 117, 108, 116, 10, 4, 0, 20, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 114, 101, 115, 117, 108, 116, 3, 0, 11, 1, 64, 1, 4, 97, 114, 103, 115, 9, 1, 0, 4, 0, 20, 99, 114, 101, 97, 116, 101, 45, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 1, 13, 1, 64, 0, 1, 0, 4, 0, 16, 104, 97, 110, 100, 108, 101, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 14, 3, 1, 60, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 2, 1, 66, 2, 1, 64, 0, 1, 0, 4, 0, 4, 109, 97, 105, 110, 1, 0, 4, 1, 39, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 109, 97, 105, 110, 64, 48, 46, 49, 46, 48, 5, 3, 4, 1, 36, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 110, 101, 119, 45, 109, 97, 105, 110, 64, 48, 46, 49, 46, 48, 4, 0, 11, 14, 1, 0, 8, 110, 101, 119, 45, 109, 97, 105, 110, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48];
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 797] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 159, 5, 1, 65, 2, 1, 65, 7, 1, 66, 17, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 2, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 100, 117, 112, 108, 105, 99, 97, 116, 101, 1, 8, 1, 111, 2, 115, 4, 1, 112, 9, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 10, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 11, 3, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 0, 2, 3, 0, 0, 6, 111, 117, 116, 112, 117, 116, 1, 66, 16, 2, 3, 2, 1, 1, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 107, 121, 1, 104, 1, 1, 107, 3, 1, 113, 2, 7, 108, 105, 116, 101, 114, 97, 108, 1, 2, 0, 3, 114, 101, 115, 1, 4, 0, 4, 0, 10, 101, 105, 116, 104, 101, 114, 45, 117, 51, 50, 3, 0, 5, 1, 114, 2, 4, 110, 97, 109, 101, 115, 6, 108, 101, 110, 103, 116, 104, 3, 4, 0, 18, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 97, 114, 103, 115, 3, 0, 7, 1, 105, 1, 1, 114, 2, 3, 117, 114, 108, 9, 6, 114, 101, 115, 117, 108, 116, 9, 4, 0, 20, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 114, 101, 115, 117, 108, 116, 3, 0, 10, 1, 64, 1, 4, 97, 114, 103, 115, 8, 1, 0, 4, 0, 20, 99, 114, 101, 97, 116, 101, 45, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 1, 12, 1, 64, 0, 1, 0, 4, 0, 16, 104, 97, 110, 100, 108, 101, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 13, 3, 1, 60, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 2, 1, 66, 2, 1, 64, 0, 1, 0, 4, 0, 4, 109, 97, 105, 110, 1, 0, 4, 1, 39, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 109, 97, 105, 110, 64, 48, 46, 49, 46, 48, 5, 3, 4, 1, 36, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 110, 101, 119, 45, 109, 97, 105, 110, 64, 48, 46, 49, 46, 48, 4, 0, 11, 14, 1, 0, 8, 110, 101, 119, 45, 109, 97, 105, 110, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48];

#[inline(never)]
#[doc(hidden)]
Expand Down
21 changes: 9 additions & 12 deletions pulumi_wasm_main/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
use crate::bindings::exports::component::pulumi_wasm::pulumi_main::Guest;
use bindings::component::pulumi_wasm::pulumi_provider_random_interface::{
create_random_string, RandomStringArgs,
};

use pulumi_rust_wasm::output::Output;
use crate::bindings::component::pulumi_wasm::pulumi_provider_random_interface;
use crate::random::*;

mod bindings;
mod random;

struct Component {}

impl Guest for Component {
fn main() {
let length: Output<i32> = Output::new(&1234);

let output_1 = length.get_inner();
let output_2 = output_1.duplicate();
let output_2 = unsafe { pulumi_provider_random_interface::Output::from_handle(output_2.into_handle()) };

let abc = RandomStringArgs {
// let output_1 = length.get_inner();
// let output_2 = output_1.duplicate();
// let output_2 = unsafe { pulumi_provider_random_interface::Output::from_handle(output_2.into_handle()) };
create_random_string(RandomStringArgs {
name: "test1234".to_string(),
length: Err(&output_2),
};
create_random_string(abc);
length: 3.into(),
});
}
}
26 changes: 26 additions & 0 deletions pulumi_wasm_main/src/random.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use pulumi_rust_wasm::output::Output;
use crate::bindings::component::pulumi_wasm::{output_interface, pulumi_provider_random_interface};

pub struct RandomStringArgs {
pub(crate) name: String,
pub(crate) length: Output<i32>,
}

pub fn create_random_string(
args: RandomStringArgs,
) {
let length = clone(args.length);
let args = pulumi_provider_random_interface::RandomStringArgs {
name: args.name,
length: &length,
};
pulumi_provider_random_interface::create_random_string(args);
}

fn clone<T>(output: Output<T>) -> output_interface::Output {
unsafe {
let inner = output.get_inner();
let cloned = inner.duplicate();
pulumi_provider_random_interface::Output::from_handle(cloned.into_handle())
}
}
Loading

0 comments on commit 0b6e146

Please sign in to comment.