bin+lib senhasegura-rs

Senhasegura API client for Rust

4 releases (2 breaking)

0.3.0 Aug 12, 2024
0.2.1 Aug 9, 2024
0.2.0 Aug 9, 2024
0.1.1 Aug 9, 2024
0.1.0 Aug 8, 2024

40 downloads per month

MIT license

56KB
966 lines

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

senhasegura-rs

A Rust library for interacting with senhasegura's API.
Explore the docs »

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Build
  5. Roadmap
  6. Contributing
  7. License
  8. Contact
  9. Acknowledgments

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.

(back to top)

Built With

  • Rust

(back to top)

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

See senhasegura-js/README.md.

(back to top)

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

See senhasegura-js/README.md.

For more examples, please refer to the Documentation

(back to top)

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.

  1. 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
    
  2. 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
    
  3. Generate C# bindings:

    uniffi-bindgen-cs --library target/debug/libsenhasegura_rs.so --out-dir bindings
    
  4. Generate Go bindings:

    uniffi-bindgen-go --library target/debug/libsenhasegura_rs.so --out-dir bindings
    
  5. Generate C++ bindings:

    uniffi-bindgen-cpp --library target/debug/libsenhasegura_rs.so --out-dir bindings
    
  6. 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.

(back to top)

Roadmap

Senhasegura APIs

Languages

See the open issues for a full list of proposed features (and known issues).

(back to top)

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

Gabriel Kim - gabrielkim13 - gabrielkim13@gmail.com

Project Link: https://github.com/gabrielkim13/senhasegura-rs

(back to top)

Acknowledgments

(back to top)

Dependencies

~8–23MB
~363K SLoC