Crates.io | senhasegura-rs |
lib.rs | senhasegura-rs |
version | 0.3.0 |
source | src |
created_at | 2024-08-08 19:17:40.57092 |
updated_at | 2024-08-12 13:07:59.599867 |
description | Senhasegura API client for Rust |
homepage | https://github.com/gabrielkim13/senhasegura-rs |
repository | https://github.com/gabrielkim13/senhasegura-rs |
max_upload_size | |
id | 1329893 |
size | 132,786 |
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.
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
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.
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:
Pending installation instructions for Python, C#, Go and C++...
[dependencies]
senhasegura-rs = "0.3"
Pending examples for Python, C#, Go and C++...
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)?);
For more examples, please refer to the Documentation
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.
These instructions will be automated in the future, and are documented here until then.
Generate a debug build of senhasegura-rs
, while enabling the uniffi
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.
See the open issues for a full list of proposed features (and known issues).
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!
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE
for more information.
Gabriel Kim - gabrielkim13 - gabrielkim13@gmail.com
Project Link: https://github.com/gabrielkim13/senhasegura-rs