Covers the full FFI workflow from manual extern declarations through bindgen automation, cbindgen for exporting Rust to C, and the sys crate pattern for wrapping native libraries. Shows practical build.rs configurations for linking, allowlisting specific symbols in bindgen to avoid pulling in system headers, and writing safe Drop-based wrappers around unsafe handles. The examples are comprehensive, walking through CString conversions, null checks, and proper error handling at FFI boundaries. Honest take: this is exactly the reference you want when integrating C libraries, with enough real patterns that you won't just cargo cult Stack Overflow snippets. The split between raw bindings and safe wrappers follows established Rust conventions well.

skills.sh installs
613
GitHub stars
279
last updated
Aug 21, 2026

Install

$ npx -y skills add mohitmishra786/low-level-dev-skills --skill rust-ffi --agent claude-code

Installs into .claude/skills of the current project.

Files

Rust FFI

Purpose

Guide agents through Rust's Foreign Function Interface: calling C from Rust with bindgen, exporting Rust to C with cbindgen, writing safe wrappers, linking libraries via build.rs, and structuring sys crates.

Triggers

  • "How do I call a C library from Rust?"
  • "How do I use bindgen to generate Rust bindings?"
  • "How do I export Rust functions to be called from C?"
  • "How do I write a safe wrapper around an unsafe C API?"
  • "How do I link a system library in Rust?"
  • "What is a sys crate and how do I structure one?"

Workflow

1. Calling C without bindgen (manual declarations)

// Declare external C functions manually
use std::ffi::{c_int, c_char, c_void, CStr, CString};

extern "C" {
    fn strlen(s: *const c_char) -> usize;
    fn malloc(size: usize) -> *mut c_void;
    fn free(ptr: *mut c_void);
    fn my_lib_init(config: *const c_char) -> c_int;
    fn my_lib_process(handle: *mut c_void, data: *const u8, len: usize) -> c_int;
    fn my_lib_cleanup(handle: *mut c_void);
}

Sponsors

Details

Repository
github.com/mohitmishra786/low-level-dev-skills
Categories
Documentation, Rust
First seen
Jun 3, 2026

More from mohitmishra786/low-level-dev-skills

All 54
1langgenius avatarvercel-react-best-practiceslanggenius/difyReact and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js c612skills.sh installs
2mohitmishra786 avatarrust-unsafemohitmishra786/low-level-dev-skillsRust unsafe code skill for systems programming. Use when writing or reviewing unsafe Rust, understanding what operations require unsafe, implementing safe abstr611skills.sh installs
3yangsonhung avatarnovel-writeryangsonhung/awesome-agent-skillsUse when writing, continuing, revising, or planning novels, characters, and fictional worlds.610skills.sh installs
4spatie avatarlivewire-developmentspatie/freek.devDevelops reactive Livewire 4 components. Activates when creating, updating, or modifying Livewire components; working with wire:model, wire:click, wire:loading,608skills.sh installs
5boshu2 avatarpr-retroboshu2/agentopsLearn from PR outcomes.607skills.sh installs
6marswaveai avatarlistenhub-climarswaveai/skillsListenHub CLI skills router. Routes to the correct skill based on user intent. Triggers on: "make a podcast", "explainer video", "read aloud", "TTS", "generate 602skills.sh installs