Crates.io | calculator-backend |
lib.rs | calculator-backend |
version | |
source | src |
created_at | 2025-04-01 18:16:40.003155+00 |
updated_at | 2025-04-24 18:19:41.1697+00 |
description | A simple calculator backend in Rust |
homepage | |
repository | |
max_upload_size | |
id | 1615195 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Rust Foreign Function Interface Wrapper Crate RI: Daniel Dusharm ddusharm@asrcfederal.com
External bindings make the (computer) world go round. For example, Python AI/ML projects that use performance-critical or efficient libraries do so by leveraging foreign function interfaces (FFI) to call native code. This project demonstrates the development of a wrapper crate in Rust using std::ffi
to expose the functionality of an external C library while ensuring type safety. Students will gain hands-on experience with Rust fundamentals such as memory safety, ownership, and FFI integration.
This project implements a calculator library that demonstrates Rust-C FFI integration. It consists of a C library for core calculations and a Rust wrapper providing a safe interface through a command-line interface (CLI).
To start the calculator application, run the following command:
cargo run --bin main
This implementation aligns with the project goals in several ways:
FFI Integration
std::ffi
for C interopMemory Safety
Error Handling
Type Safety
The project handles memory safety through:
Error types include:
Handles conversions between:
cargo test
cargo test --test <test_name>
Current limitations:
Planned improvements:
Additional Mathematical Functions
Expression Optimization
This project is part of academic coursework and is subject to course guidelines.