-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bindings: First version of the uniffi bindings
- Loading branch information
Showing
11 changed files
with
595 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "gl-client-bindings" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
name = "glclient" | ||
|
||
[dependencies] | ||
anyhow.workspace = true | ||
gl-client = { path = "../gl-client", features = ["permissive"] } | ||
thiserror = "1.0.56" | ||
tokio = { version = "1", features = [], default-features = false} | ||
uniffi = { version = "0.24" } | ||
once_cell = "*" | ||
|
||
[build-dependencies] | ||
uniffi = { version = "0.24", features = [ "build" ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
.PHONY: generate | ||
|
||
GENERATED := \ | ||
src/glclient.py \ | ||
src/glclient.rb \ | ||
src/glclient.swift \ | ||
src/glclient/glclient.go \ | ||
src/glclient/glclient.c \ | ||
src/glclient/glclient.h \ | ||
src/uniffi/glclient/glclient.kt | ||
|
||
generate: src/glclient.py src/glclient.go src/glclient.rb src/glclient.swift src/glclient.kt | ||
|
||
src/glclient.swift: src/glclient.udl src/glclient.uniffi.rs | ||
cargo run -p uniffi-bindgen --features=uniffi/cli generate src/glclient.udl --language swift --no-format | ||
|
||
src/glclient.rb: src/glclient.udl src/glclient.uniffi.rs | ||
cargo run -p uniffi-bindgen --features=uniffi/cli generate src/glclient.udl --language ruby --no-format | ||
|
||
src/uniffi/glclient/glclient.kt: src/glclient.udl src/glclient.uniffi.rs | ||
cargo run -p uniffi-bindgen --features=uniffi/cli generate src/glclient.udl --language kotlin --no-format | ||
|
||
src/glclient.py: src/glclient.udl src/glclient.uniffi.rs | ||
cargo run -p uniffi-bindgen --features=uniffi/cli generate src/glclient.udl --language python --no-format | ||
|
||
src/glclient/glclient.h src/glclient/glclient.c src/glclientglclient.go: src/glclient.udl src/glclient.uniffi.rs | ||
uniffi-bindgen-go src/glclient.udl --no-format | ||
|
||
src/glclient.uniffi.rs: src/glclient.udl | ||
cargo run -p uniffi-bindgen --features=uniffi/cli scaffolding src/glclient.udl --no-format | ||
|
||
clean: | ||
rm -fv ${GENERATED} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
uniffi::generate_scaffolding("src/glclient.udl").unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum Error { | ||
#[error("unhandled error: {0}")] | ||
Other(#[from] anyhow::Error), | ||
#[error("Invalid argument error: {0}")] | ||
InvalidArgument(Box<dyn std::error::Error + Send + Sync>), | ||
#[error("Error while calling {method}: {error}")] | ||
Call { | ||
method: String, | ||
error: String, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace glclient { | ||
}; | ||
|
||
[Error] | ||
enum Error { | ||
"Call", | ||
"Other", | ||
"InvalidArgument", | ||
}; | ||
|
||
interface Scheduler { | ||
|
||
[Throws=Error] | ||
constructor(bytes node_id, string network); | ||
|
||
[Throws=Error] | ||
void authenticate(bytes cert_pem, bytes key_pem); | ||
}; | ||
|
||
interface RawClient { | ||
[Throws=Error] | ||
constructor( | ||
bytes node_id, | ||
string network, | ||
bytes cert_pem, | ||
bytes key_pem, | ||
string node_uri | ||
); | ||
|
||
[Throws=Error] | ||
bytes call(string method, bytes payload); | ||
}; |
Oops, something went wrong.