4 releases (2 breaking)
0.3.0 | Aug 12, 2024 |
---|---|
0.2.1 | Aug 9, 2024 |
0.2.0 |
|
0.1.1 | Aug 9, 2024 |
0.1.0 | Aug 8, 2024 |
#706 in Web programming
159 downloads per month
56KB
966 lines
Table of Contents
About The Project
A Rust library for interacting with senhasegura's API.
The goal of this project is to enable interaction with senhasegura's APIs in many languages /
runtimes while maintaining a single core codebase (i.e. senhasegura-rs
) and several other
libraries bound to it.
Built With
Getting Started
Prerequisites
Cross-compilation
In order to cross-compile to Windows MSVC target, install cargo-xwin:
# Clang
sudo apt install clang
# For assembly dependencies, which is the case
rustup component add llvm-tools-preview
# cargo-xwin
cargo install --locked cargo-xwin
# Windows x64 MSVC target
rustup target add x86_64-pc-windows-msvc
NAPI-RS
This project uses NAPI-RS to generate JS bindings, adding first-class support for Node.js.
In order to work on the senhasegura-js library project, an installation of Node.js is required.
UniFFI
This project uses UniFFI to generate bindings for multiple languages, such as Python, C#, Go and C++.
UniFFI supports generating Python bindings out of the box and nothing else is required to generate its bindings. However, C#, Go and C++ bindings require installing third-party bindgen tooling:
Installation
Pending installation instructions for Python, C#, Go and C++...
Rust
[dependencies]
senhasegura-rs = "0.3"
Node.js
Usage
Pending examples for Python, C#, Go and C++...
Rust
use senhasegura_rs::{AccessProtectedInformationAPI, SenhaseguraClient};
let base_url = "https://senhasegura.acme.com".parse()?;
let client_id = "client_id";
let client_secret = "client_secret";
let client = SenhaseguraClient::builder(base_url, client_id, client_secret).build()?;
// Access protected information
println!("{:#?}", client.access_protected_information(28)?);
Node.js
For more examples, please refer to the Documentation
Build
NAPI-RS
The build process for the JS bindings of the library is automated by napi
's CLI:
cd senhasegura-js
yarn build
The generated bindings and binaries (i.e. *.node
files) are kept at the root of the
senhasegura-js folder, but are ignored by Git.
UniFFI
These instructions will be automated in the future, and are documented here until then.
-
Generate a debug build of
senhasegura-rs
, while enabling theuniffi
feature:This is necessary for keeping the UniFFI metadata present in the binary itself.
cargo build -p senhasegura-rs --features uniffi
-
Generate Python bindings:
cargo run -p senhasegura-rs \ --features=uniffi/cli \ --bin uniffi-bindgen \ generate \ --library target/debug/libsenhasegura_rs.so \ -l python \ --out-dir bindings \ --no-format
-
Generate C# bindings:
uniffi-bindgen-cs --library target/debug/libsenhasegura_rs.so --out-dir bindings
-
Generate Go bindings:
uniffi-bindgen-go --library target/debug/libsenhasegura_rs.so --out-dir bindings
-
Generate C++ bindings:
uniffi-bindgen-cpp --library target/debug/libsenhasegura_rs.so --out-dir bindings
-
Generate the Linux / Windows x64 release binaries and copy them into the :
# Linux x64 (native) cargo build -p senhasegura-rs --features uniffi --release # Windows x64 MSVC cargo xwin build -p senhasegura-rs --features uniffi --release --target x86_64-pc-windows-msvc # Copy libraries cp \ target/release/libsenhasegura_rs.so \ target/x86_64-pc-windows-msvc/release/senhasegura_rs.dll \ bindings
All generated bindings are kept in the bindings folder, but are ignored by Git.
Roadmap
Senhasegura APIs
Languages
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Gabriel Kim - gabrielkim13 - gabrielkim13@gmail.com
Project Link: https://github.com/gabrielkim13/senhasegura-rs
Acknowledgments
Dependencies
~9–24MB
~359K SLoC