risc0_zkvm_circuit_sys/
lib.rs

1// Copyright 2022 Risc0, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#![doc = include_str!("README.md")]
16
17use anyhow::Result;
18use cxx::let_cxx_string;
19
20#[cxx::bridge(namespace = "risc0::circuit")]
21mod ffi {
22    unsafe extern "C++" {
23        include!("risc0/zkvm/circuit/make_circuit.h");
24
25        fn make_circuit(path: &CxxString) -> Result<()>;
26    }
27}
28
29/// Produces a machine generated .h file that implements the RISC-V circuit and writes it to a file.
30pub fn make_circuit(path: &str) -> Result<()> {
31    let_cxx_string!(path = path);
32    Ok(ffi::make_circuit(&path)?)
33}