mlx-c-rust 0.32.4-alpha.3

A complete, low-level, policy-free Rust bridge to the MLX-C API of Apple's MLX for Apple silicon, tracking MLX releases. Version = the verified MLX release (0.32.4; carries MLX-C 0.7 forward).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Safe wrapper over the MLX AOT metallib path override.

use std::ffi::{CStr, c_char};

use crate::{MlxCError, error::check_status, raw};

/// Overrides the metallib MLX loads.
///
/// The policy owner resolves and verifies WHICH metallib to load; this wrapper
/// only performs the official override call.
pub fn set_metallib_path(path: &CStr) -> Result<(), MlxCError> {
    let nul_terminated_path: *const c_char = path.as_ptr();
    // SAFETY: The official C API copies the non-null NUL-terminated path and
    // does not retain the borrowed pointer after returning.
    let status = unsafe { raw::mlx_metal_set_metallib_path(nul_terminated_path) };
    check_status(status, "set the MLX AOT metallib path")
}