soroban_cli/commands/contract/
bindings.rs

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