| Crates.io | metacall |
| lib.rs | metacall |
| version | 0.5.2 |
| created_at | 2020-10-23 10:02:53.333947+00 |
| updated_at | 2025-09-17 19:56:21.591797+00 |
| description | Call NodeJS, TypeScript, Python, C#, Ruby... functions from Rust (a Rust Port for MetaCall). |
| homepage | |
| repository | https://github.com/metacall/core/tree/develop/source/ports/rs_port |
| max_upload_size | |
| id | 304622 |
| size | 235,957 |
M E T A C A L L
A library for providing inter-language foreign function interface calls
METACALL is a library that allows calling functions, methods or procedures between programming languages. With METACALL you can transparently execute code from / to any programming language, for example, call TypeScript code from Rust.
MetaCall is a C plugin based library. This crate wraps the C library into Rust, so in order to make it work, you should install MetaCall binaries first (click here for installing it on other platforms):
curl -sL https://raw.githubusercontent.com/metacall/install/master/install.sh | sh
If your project uses MetaCall in a folder that is not in the system path, we encourage to use metacall-sys crate as a build-dependecy. By this way you will be able to locate and link MetaCall directly in your build system. For example:
Cargo.toml:
[build-dependencies]
metacall-sys = "0.1.2"
build.rs:
fn main() {
// Find MetaCall library
metacall_sys::build();
}
sum.ts
export function sum(a: number, b: number): number {
return a + b;
}
main.rs
use metacall::{initialize, metacall, load};
fn main() {
// Initialize MetaCall at the top
let _metacall = initialize().unwrap();
// Load the file
load::from_single_file("ts", "sum.ts").unwrap();
// Call the sum function
let sum = metacall::<f64>("sum", [1.0, 2.0]).unwrap();
assert_eq!(sum, 3.0);
}