karlosmid / siwe-ex Goto Github PK
View Code? Open in Web Editor NEWThis project forked from spruceid/siwe-ex
Sign-In with Ethereum Implementation for Elixir
License: Apache License 2.0
This project forked from spruceid/siwe-ex
Sign-In with Ethereum Implementation for Elixir
License: Apache License 2.0
To use rustler_precompiled in an Elixir project, you need to follow these steps:
Add rustler_precompiled as a dependency in your mix.exs file. Update the deps function as follows:
elixir
Copy code
defp deps do
[
{:rustler_precompiled, "~> 0.22"}
]
end
In your Elixir code, define a Rust module and declare the NIF functions using rustler_precompiled. Here's an example:
elixir
Copy code
defmodule MyRustModule do
use Rustler.Precompiled
defnif add(a, b), do: :rustler_precompiled.add(a, b)
defnif subtract(a, b), do: :rustler_precompiled.subtract(a, b)
end
In this example, we define two NIF functions, add and subtract, which are wrappers around the Rust NIF functions implemented in Rust.
In your mix.exs file, add the configuration for rustler_precompiled in the project function:
elixir
Copy code
def project do
[
...
compilers: Mix.compilers() ++ [:rustler_precompiled],
rustler_precompiled: [crate_path: "path/to/your/rust/project"],
...
]
end
Replace "path/to/your/rust/project" with the actual path to your Rust project. This configuration tells rustler_precompiled where to find your Rust project and compile it into a NIF.
Build your Elixir project by running mix compile. This will compile both your Elixir code and the Rust code.
Load and use the Rust NIF functions in your Elixir code. Here's an example usage:
elixir
Copy code
a = 5
b = 3
result = MyRustModule.add(a, b)
IO.puts("Result of adding #{a} and #{b} is: #{result}")
result = MyRustModule.subtract(a, b)
IO.puts("Result of subtracting #{b} from #{a} is: #{result}")
In this example, we call the add and subtract functions from the MyRustModule module, which internally invokes the Rust NIF functions implemented using rustler_precompiled.
Run your Elixir code using mix run or start your application using mix run --no-halt or iex -S mix.
By following these steps, you can integrate rustler_precompiled and use Rust NIFs in your Elixir project. Make sure to have Rust installed on your system and properly configure the Rust project and module names in the Elixir code. For more information and advanced usage, refer to the rustler_precompiled documentation and examples.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.