polyglot-bindings

Create and maintain language bindings around a Rust core library.

836|66|Updated Feb 3, 2025
One-click install
npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill polyglot-bindings
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: polyglot-bindings
Source: https://github.com/kreuzberg-dev/html-to-markdown/tree/main/.codex/skills/polyglot-bindings
Command: npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill polyglot-bindings

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides patterns and guidance for creating and maintaining language bindings around a Rust core library, simplifying cross-language development.

Core Features & Use Cases

  • Type Mapping: Handles conversion between Rust types and host language types.
  • Error Handling: Manages conversion of Rust Results into host language exceptions.
  • Memory Management: Integrates Rust's memory management with host language garbage collection or reference counting.
  • Concurrency Adaptation: Bridges Rust's concurrency models (like Tokio) with host language runtimes.
  • Use Case: A Rust library for high-performance image processing needs to be accessible from Python. This Skill's patterns ensure a smooth, idiomatic Python API is created, handling all the underlying complexities.

Quick Start

Use the polyglot-bindings skill to generate a Python binding for a Rust function that calculates prime numbers.

Frequently Asked Questions about polyglot-bindings

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create language bindings for a Rust core library?

To create language bindings for a Rust core library, you need patterns for type mapping, error conversion, memory management, and concurrency adaptation to ensure an idiomatic API surface across target languages.

What is the best way to expose a Rust library to Python, TypeScript, and Go?

Exposing a Rust library to Python, TypeScript, and Go requires bridging Rust's concurrency models with host language runtimes and converting Rust Results into host language exceptions for seamless cross-language integration.

How does FFI handle memory management between Rust and garbage-collected languages?

FFI handles memory management by integrating Rust's ownership model with host language garbage collection or reference counting, preventing memory leaks when passing data across the language boundary.

Can I adapt Rust's Tokio concurrency model for cross-language bindings?

Yes, adapting Rust's Tokio concurrency model for cross-language bindings is possible by bridging async Rust runtimes with host language execution environments to maintain non-blocking behavior.

How do I convert Rust errors into exceptions for PHP, Ruby, and Java bindings?

Converting Rust errors into exceptions for PHP, Ruby, and Java bindings involves error conversion patterns that translate Rust Result variants into appropriate host language exception types.

Do I need to write separate C FFI layers for each target language binding?

You can use a C FFI layer as a foundational bridge, but creating language-idiomatic API surfaces requires adapting type mapping and memory management specifically for each host language like C# or WASM.