soroban_cli/commands/contract/
bindings.rs

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