use std::ffi::{CString, c_char, c_int};
use crate::MlxBindingsContext;
use crate::{MlxCError, error::check_status};
unsafe extern "C" {
fn mlx_metal_start_capture(path: *const c_char) -> c_int;
fn mlx_metal_stop_capture() -> c_int;
}
impl MlxBindingsContext {
pub fn start_metal_capture(&self, capture_path: &str) -> Result<(), MlxCError> {
const OPERATION: &str = "start an MLX Metal capture";
let capture_path = CString::new(capture_path).map_err(|source| MlxCError {
operation: OPERATION,
description: format!("capture path contains an interior NUL byte: {source}"),
})?;
let status = unsafe { mlx_metal_start_capture(capture_path.as_ptr()) };
check_status(status, OPERATION)
}
pub fn stop_metal_capture(&self) -> Result<(), MlxCError> {
const OPERATION: &str = "stop an MLX Metal capture";
let status = unsafe { mlx_metal_stop_capture() };
check_status(status, OPERATION)
}
}