Expand description
§pyroxide
Zero-copy FFI bridge between Rust and Mojo — the glowing bridge between oxidation and fire.
§Safety model
- No dangling pointers:
MojoRefties the pointer’s validity to the Rust borrow’s lifetime. - No panics across FFI:
catch_mojo_callcatches panics at the boundary, preventing undefined behavior. - No layout mismatch:
mojo_type!enforces#[repr(C)]and zerocopy derives at compile time. - Ownership is explicit: Rust owns the data, Mojo borrows via pointer.
§Quick start
ⓘ
use pyroxide::prelude::*;
mojo_type! {
pub struct Vec3 { pub x: f64, pub y: f64, pub z: f64 }
}
unsafe extern "C" {
fn vec3_length(addr: isize) -> f64;
}
let v = Vec3 { x: 3.0, y: 4.0, z: 0.0 };
let len = unsafe { vec3_length(v.as_raw()) };§Feature flags
max— Types matching the Modular MAX ML framework (DType,TensorShape,TensorDescriptor,Tensor,TensorView)
Modules§
- abi
- Mojo
@exportABI documentation and helpers. - bridge
- Core traits and handle types for the Rust↔Mojo FFI boundary.
- prelude
- string
- FFI-safe string type for passing text between Rust and Mojo.
- trampoline
- Panic-safe trampoline for the Rust↔Mojo FFI boundary.
- types
- Types for the Mojo FFI bridge.
Macros§
- mojo_
type - Declare a struct that can safely cross the Mojo FFI boundary.