Skip to main content

soroban_cli/commands/contract/
bindings.rs

1pub mod flutter;
2pub mod java;
3pub mod php;
4pub mod python;
5pub mod rust;
6pub mod swift;
7pub mod typescript;
8
9#[derive(Debug, clap::Subcommand)]
10pub enum Cmd {
11    /// Generate Rust bindings
12    Rust(rust::Cmd),
13
14    /// Generate a TypeScript / JavaScript package
15    Typescript(Box<typescript::Cmd>),
16
17    /// Generate Python bindings
18    Python(python::Cmd),
19
20    /// Generate Java bindings
21    Java(java::Cmd),
22
23    /// Generate Flutter bindings
24    Flutter(flutter::Cmd),
25
26    /// Generate Swift bindings
27    Swift(swift::Cmd),
28
29    /// Generate PHP bindings
30    Php(php::Cmd),
31}
32
33#[derive(thiserror::Error, Debug)]
34pub enum Error {
35    #[error(transparent)]
36    Rust(#[from] rust::Error),
37
38    #[error(transparent)]
39    Typescript(#[from] typescript::Error),
40
41    #[error(transparent)]
42    Python(#[from] python::Error),
43
44    #[error(transparent)]
45    Java(#[from] java::Error),
46
47    #[error(transparent)]
48    Flutter(#[from] flutter::Error),
49
50    #[error(transparent)]
51    Swift(#[from] swift::Error),
52
53    #[error(transparent)]
54    Php(#[from] php::Error),
55}
56
57impl Cmd {
58    pub async fn run(&self) -> Result<(), Error> {
59        match &self {
60            Cmd::Rust(rust) => rust.run()?,
61            Cmd::Typescript(ts) => ts.run().await?,
62            Cmd::Python(python) => python.run()?,
63            Cmd::Java(java) => java.run()?,
64            Cmd::Flutter(flutter) => flutter.run()?,
65            Cmd::Swift(swift) => swift.run()?,
66            Cmd::Php(php) => php.run()?,
67        }
68        Ok(())
69    }
70}