clone_solana_instruction/
wasm.rs

1//! The `Instructions` struct is a legacy workaround
2//! from when wasm-bindgen lacked Vec<T> support
3//! (ref: https://github.com/rustwasm/wasm-bindgen/issues/111)
4use {crate::Instruction, wasm_bindgen::prelude::*};
5
6#[wasm_bindgen]
7#[derive(Default)]
8pub struct Instructions {
9    instructions: std::vec::Vec<Instruction>,
10}
11
12#[wasm_bindgen]
13impl Instructions {
14    #[wasm_bindgen(constructor)]
15    pub fn constructor() -> Instructions {
16        Instructions::default()
17    }
18
19    pub fn push(&mut self, instruction: Instruction) {
20        self.instructions.push(instruction);
21    }
22}
23
24impl From<Instructions> for std::vec::Vec<Instruction> {
25    fn from(instructions: Instructions) -> Self {
26        instructions.instructions
27    }
28}