This is an automated email from the ASF dual-hosted git repository.

xiaokang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-graphar.git


The following commit(s) were added to refs/heads/main by this push:
     new 14d034fc feat(Rust): add Rust bindings skeleton and Rust CI  (#808)
14d034fc is described below

commit 14d034fc2114769d3f7a8a622e8ece340e63d682
Author: Jinye Wu <[email protected]>
AuthorDate: Wed Dec 17 15:52:36 2025 +0800

    feat(Rust): add Rust bindings skeleton and Rust CI  (#808)
    
    * ci and skeleton
    
    * update
    
    * update comment
    
    * update ci
    
    * update license comment and ci
    
    * makes taplo happy
    
    * fix dockerfile, ci and build.rs
---
 .github/workflows/rust.yaml | 153 ++++++++++++++++++++++
 rust/Cargo.lock             | 301 ++++++++++++++++++++++++++++++++++++++++++++
 rust/Cargo.toml             |  30 +++++
 rust/Dockerfile             |  52 ++++++++
 rust/build.rs               |  91 ++++++++++++++
 rust/deny.toml              |  47 +++++++
 rust/include/graphar_rs.h   |  25 ++++
 rust/rust-toolchain.toml    |  20 +++
 rust/src/ffi.rs             |  37 ++++++
 rust/src/graphar_rs.cc      |  25 ++++
 rust/src/lib.rs             |  18 +++
 rust/taplo.toml             |  19 +++
 12 files changed, 818 insertions(+)

diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml
new file mode 100644
index 00000000..26c16e52
--- /dev/null
+++ b/.github/workflows/rust.yaml
@@ -0,0 +1,153 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: GraphAr Rust CI
+
+on:
+  push:
+    branches:
+      - "main"
+    paths:
+      - "rust/**"
+      - "cpp/**"
+      - ".github/workflows/rust.yaml"
+  pull_request:
+    branches:
+      - "main"
+    paths:
+      - "rust/**"
+      - "cpp/**"
+      - ".github/workflows/rust.yaml"
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
+env:
+  RUSTFLAGS: -Dwarnings
+  RUST_BACKTRACE: 1
+  CI: true
+
+defaults:
+  run:
+    shell: bash
+
+jobs:
+  ubuntu:
+    name: Ubuntu latest Rust
+    runs-on: ubuntu-24.04
+    # run on draft
+    if: ${{ github.event_name != 'pull_request' || 
!contains(github.event.pull_request.title, 'WIP') }}
+    env:
+      GAR_TEST_DATA: ${{ github.workspace }}/testing/
+    defaults:
+      run:
+        working-directory: "rust"
+    steps:
+      - uses: actions/checkout@v4
+        with:
+          submodules: true
+
+      - uses: Swatinem/rust-cache@v2
+        with:
+          workspaces: "rust -> target"
+
+      - name: Install cargo-nextest
+        uses: taiki-e/install-action@v2
+        with:
+          tool: [email protected]
+          
+      - name: Install cargo-machete
+        uses: taiki-e/install-action@v2
+        with:
+          tool: [email protected]
+
+      - name: Install taplo-cli
+        uses: taiki-e/install-action@v2
+        with:
+          tool: [email protected]
+
+      - name: Install cargo-llvm-cov
+        uses: taiki-e/install-action@v2
+        with:
+          tool: [email protected]
+
+      - name: Install cargo-deny
+        uses: taiki-e/install-action@v2
+        with:
+          tool: [email protected]
+
+      - name: Install dependencies
+        run: |
+          wget -c https://apache.jfrog.io/artifactory/arrow/"$(lsb_release 
--id --short | tr 'A-Z' 'a-z')"/apache-arrow-apt-source-latest-$(lsb_release 
--codename --short).deb \
+            -P /tmp/
+          sudo apt-get install -y 
/tmp/apache-arrow-apt-source-latest-"$(lsb_release --codename --short)".deb
+          sudo apt-get update -y
+          sudo apt install -y libarrow-dev=22.0.0-1 \
+                            libarrow-dataset-dev=22.0.0-1 \
+                            libarrow-acero-dev=22.0.0-1 \
+                            libparquet-dev=22.0.0-1
+          sudo apt-get install -y libboost-graph-dev ccache 
libcurl4-openssl-dev doxygen lcov cmake
+
+      - name: Spell Check
+        uses: crate-ci/[email protected]
+        with:
+          files: rust/
+        timeout-minutes: 10
+
+      - name: TOML Check
+        run: taplo fmt --check --diff
+        timeout-minutes: 10
+
+      - name: Rustfmt Check
+        run: cargo fmt --all --check
+        timeout-minutes: 10
+
+      - name: Clippy Check
+        run: cargo clippy --tests --no-deps
+        timeout-minutes: 10
+
+      - name: Machete Check
+        run: cargo machete
+        timeout-minutes: 10
+
+      - name: Deny Check
+        run: cargo deny check
+
+      - name: Build
+        run: cargo build
+        timeout-minutes: 30
+
+      - name: Test
+        run: |
+          cargo nextest run
+          cargo test --doc
+        timeout-minutes: 30
+
+      - name: Build Docs
+        run: cargo doc --lib --no-deps
+        timeout-minutes: 30
+
+      - name: Generate code coverage
+        run: cargo llvm-cov --all-features --workspace --lcov --output-path 
lcov.info
+
+      - name: Upload coverage to Codecov
+        uses: codecov/codecov-action@v5
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }} # required for private repos or 
protected branches
+          files: lcov.info
+          fail_ci_if_error: true
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
new file mode 100644
index 00000000..4317f99b
--- /dev/null
+++ b/rust/Cargo.lock
@@ -0,0 +1,301 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "anstyle"
+version = "1.0.13"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
+
+[[package]]
+name = "cc"
+version = "1.2.49"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "90583009037521a116abf44494efecd645ba48b6622457080f080b85544e2215"
+dependencies = [
+ "find-msvc-tools",
+ "shlex",
+]
+
+[[package]]
+name = "clap"
+version = "4.5.53"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8"
+dependencies = [
+ "clap_builder",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.5.53"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00"
+dependencies = [
+ "anstyle",
+ "clap_lex",
+ "strsim",
+]
+
+[[package]]
+name = "clap_lex"
+version = "0.7.6"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
+
+[[package]]
+name = "cmake"
+version = "0.1.54"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "codespan-reporting"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681"
+dependencies = [
+ "serde",
+ "termcolor",
+ "unicode-width",
+]
+
+[[package]]
+name = "cxx"
+version = "1.0.190"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "a7620f6cfc4dcca21f2b085b7a890e16c60fd66f560cd69ee60594908dc72ab1"
+dependencies = [
+ "cc",
+ "cxx-build",
+ "cxxbridge-cmd",
+ "cxxbridge-flags",
+ "cxxbridge-macro",
+ "foldhash",
+ "link-cplusplus",
+]
+
+[[package]]
+name = "cxx-build"
+version = "1.0.190"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "7a9bc1a22964ff6a355fbec24cf68266a0ed28f8b84c0864c386474ea3d0e479"
+dependencies = [
+ "cc",
+ "codespan-reporting",
+ "indexmap",
+ "proc-macro2",
+ "quote",
+ "scratch",
+ "syn",
+]
+
+[[package]]
+name = "cxxbridge-cmd"
+version = "1.0.190"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "b1f29a879d35f7906e3c9b77d7a1005a6a0787d330c09dfe4ffb5f617728cb44"
+dependencies = [
+ "clap",
+ "codespan-reporting",
+ "indexmap",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "cxxbridge-flags"
+version = "1.0.190"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "d67109015f93f683e364085aa6489a5b2118b4a40058482101d699936a7836d6"
+
+[[package]]
+name = "cxxbridge-macro"
+version = "1.0.190"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "d187e019e7b05a1f3e69a8396b70800ee867aa9fc2ab972761173ccee03742df"
+dependencies = [
+ "indexmap",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "equivalent"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
+
+[[package]]
+name = "find-msvc-tools"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844"
+
+[[package]]
+name = "foldhash"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
+
+[[package]]
+name = "graphar-rs"
+version = "0.1.0"
+dependencies = [
+ "cmake",
+ "cxx",
+ "cxx-build",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.16.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
+
+[[package]]
+name = "indexmap"
+version = "2.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2"
+dependencies = [
+ "equivalent",
+ "hashbrown",
+]
+
+[[package]]
+name = "link-cplusplus"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "7f78c730aaa7d0b9336a299029ea49f9ee53b0ed06e9202e8cb7db9bae7b8c82"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.103"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.42"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "scratch"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "d68f2ec51b097e4c1a75b681a8bec621909b5e91f15bb7b840c4f2f7b01148b2"
+
+[[package]]
+name = "serde"
+version = "1.0.228"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
+dependencies = [
+ "serde_core",
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.228"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.228"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "shlex"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
+
+[[package]]
+name = "strsim"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+[[package]]
+name = "syn"
+version = "2.0.111"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "termcolor"
+version = "1.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.22"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
+
+[[package]]
+name = "unicode-width"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
+
+[[package]]
+name = "winapi-util"
+version = "0.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[package]]
+name = "windows-sys"
+version = "0.61.2"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
+dependencies = [
+ "windows-link",
+]
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
new file mode 100644
index 00000000..71b9f07b
--- /dev/null
+++ b/rust/Cargo.toml
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[package]
+name = "graphar-rs"
+version = "0.1.0"
+edition = "2024"
+license = "Apache-2.0"
+
+[dependencies]
+# anyhow = "1.0.100"
+cxx = "1.0.190"
+
+[build-dependencies]
+cxx-build = "1.0.190"
+cmake = "0.1.54"
diff --git a/rust/Dockerfile b/rust/Dockerfile
new file mode 100644
index 00000000..6d155f44
--- /dev/null
+++ b/rust/Dockerfile
@@ -0,0 +1,52 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Derived from Graphar
+# 
https://github.com/apache/incubator-graphar/blob/main/.devcontainer/Dockerfile
+
+# A script to install dependencies required for release
+# verification on Ubuntu.
+FROM ubuntu:24.04
+
+RUN apt-get update &&                                            \
+    apt-get install -y --no-install-recommends         \
+      build-essential                                      \
+      cmake                                                \
+      curl                                                 \
+      wget                                                                 \
+      git ca-certificates                              \
+      lsb-release                               \
+      clang clangd clang-format vim 
+
+RUN wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short 
| tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename 
--short).deb    \
+    && apt-get install -y ./apache-arrow-apt-source-latest-$(lsb_release 
--codename --short).deb                                                         
               \
+    && apt-get update                                                          
                                                                                
         \
+    && apt-get install -y                                                      
                                                                                
         \
+        libarrow-dev=22.0.0-1                                                  
                                                                                
         \
+        libarrow-dataset-dev=22.0.0-1                                          
                                                                                
         \
+        libarrow-acero-dev=22.0.0-1                                            
                                                                                
         \
+        libparquet-dev=22.0.0-1                                                
                                                                                
         \
+        libarrow-compute-dev=22.0.0-1                                          
                                                                                
         \
+        libboost-graph-dev
+
+RUN apt-get clean -y &&                                            \
+    rm -rf /var/lib/apt/lists/* ./apache-arrow-apt-source-latest-$(lsb_release 
--codename --short).deb
+
+# install rust toolchain
+RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
+
+WORKDIR /workspace
diff --git a/rust/build.rs b/rust/build.rs
new file mode 100644
index 00000000..b8cefe46
--- /dev/null
+++ b/rust/build.rs
@@ -0,0 +1,91 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Portions adapted from 
`https://github.com/kuzudb/kuzu/blob/master/tools/rust_api/build.rs` (MIT 
License).
+use std::env;
+use std::path::{Path, PathBuf};
+
+fn link_libraries() {
+    // Link to system Arrow, `libarrow` is under `/usr/lib/x86_64-linux-gnu/` 
on Ubuntu
+    println!("cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu/");
+    println!("cargo:rustc-link-lib=dylib=arrow_compute");
+    println!("cargo:rustc-link-lib=dylib=arrow_dataset");
+    println!("cargo:rustc-link-lib=dylib=arrow_acero");
+    println!("cargo:rustc-link-lib=dylib=arrow");
+
+    println!("cargo:rustc-link-lib=graphar");
+}
+
+fn build_ffi(bridge_file: &str, out_name: &str, source_file: &str, 
include_paths: &[PathBuf]) {
+    let mut build = cxx_build::bridge(bridge_file);
+    build.file(source_file);
+
+    build.includes(include_paths);
+    // TODO support MSVC
+    build.flag("-std=c++17");
+    build.flag("-fdiagnostics-color=always");
+
+    build.compile(out_name);
+}
+
+fn build_graphar() -> Vec<PathBuf> {
+    let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("..").join("cpp");
+    let mut build = cmake::Config::new(&root);
+
+    // 1. Check if `GRAPHAR_BUILD_TYPE` is set. The value must be `Release`, 
`Debug` or `RelWithDebInfo`
+    // 2. If not, fallback to `PROFILE` which is set by `cargo`
+    let cmake_build_type =
+        env::var("GRAPHAR_BUILD_TYPE").unwrap_or_else(|_| match 
env::var("PROFILE").as_deref() {
+            Ok("release") => "Release".to_string(),
+            _ => "Debug".to_string(),
+        });
+
+    println!("cargo:rerun-if-env-changed=GRAPHAR_BUILD_TYPE");
+    println!("cargo:rerun-if-env-changed=PROFILE");
+
+    build
+        .no_build_target(true)
+        .define("CMAKE_BUILD_TYPE", cmake_build_type)
+        .define("GRAPHAR_BUILD_STATIC", "on");
+    let build_dir = build.build();
+
+    let lib_path = build_dir.join("build");
+    println!("cargo:rustc-link-search=native={}", lib_path.display());
+
+    println!("cargo:rerun-if-changed=include/graphar_rs.h");
+    println!("cargo:rerun-if-changed=src/graphar_rs.cc");
+    println!("cargo:rerun-if-changed=../cpp");
+
+    // Include `cpp/src` and `thirdparty`
+    vec![root.join("src/"), root.join("thirdparty/")]
+}
+
+fn main() {
+    // Include `include/`
+    let mut include_paths = 
vec![Path::new(env!("CARGO_MANIFEST_DIR")).join("include")];
+    include_paths.extend(build_graphar());
+
+    link_libraries();
+
+    // Build files generated by `ffi.rs` and `graphar_rs.cc`
+    build_ffi(
+        "src/ffi.rs",
+        "graphar_cxx",
+        "src/graphar_rs.cc",
+        &include_paths,
+    );
+}
diff --git a/rust/deny.toml b/rust/deny.toml
new file mode 100644
index 00000000..d97501f0
--- /dev/null
+++ b/rust/deny.toml
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[graph]
+all-features = true
+
+[output]
+feature-depth = 1
+
+[advisories]
+git-fetch-with-cli = true
+unmaintained = "workspace"
+
+[licenses]
+allow = ["MIT", "Apache-2.0", "Zlib", "Unicode-3.0"]
+confidence-threshold = 0.8
+
+[licenses.private]
+ignore = false
+
+[bans]
+highlight = "all"
+multiple-versions = "warn"
+wildcards = "deny"
+
+[bans.workspace-dependencies]
+duplicates = "deny"
+unused = "deny"
+
+[sources]
+allow-registry = ["https://github.com/rust-lang/crates.io-index";]
+unknown-git = "deny"
+unknown-registry = "deny"
diff --git a/rust/include/graphar_rs.h b/rust/include/graphar_rs.h
new file mode 100644
index 00000000..b688104c
--- /dev/null
+++ b/rust/include/graphar_rs.h
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <cstdint>
+namespace graphar_rs {
+int64_t foo(int64_t x, int64_t y);
+} // namespace graphar_rs
diff --git a/rust/rust-toolchain.toml b/rust/rust-toolchain.toml
new file mode 100644
index 00000000..e4bd143b
--- /dev/null
+++ b/rust/rust-toolchain.toml
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[toolchain]
+channel = "1.91.1"
+profile = "default"
diff --git a/rust/src/ffi.rs b/rust/src/ffi.rs
new file mode 100644
index 00000000..173b2150
--- /dev/null
+++ b/rust/src/ffi.rs
@@ -0,0 +1,37 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#[cxx::bridge(namespace = "graphar")]
+pub(crate) mod graphar {
+    unsafe extern "C++" {
+        include!("graphar_rs.h");
+
+        #[allow(unused)]
+        #[namespace = "graphar_rs"]
+        fn foo(x: i64, y: i64) -> i64;
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn test_foo() {
+        assert_eq!(graphar::foo(1, 2), 3);
+    }
+}
diff --git a/rust/src/graphar_rs.cc b/rust/src/graphar_rs.cc
new file mode 100644
index 00000000..2101dc47
--- /dev/null
+++ b/rust/src/graphar_rs.cc
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "graphar_rs.h"
+namespace graphar_rs {
+
+int64_t foo(int64_t x, int64_t y) { return x + y; }
+
+} // namespace graphar_rs
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
new file mode 100644
index 00000000..2795c73c
--- /dev/null
+++ b/rust/src/lib.rs
@@ -0,0 +1,18 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+mod ffi;
diff --git a/rust/taplo.toml b/rust/taplo.toml
new file mode 100644
index 00000000..1fe94b15
--- /dev/null
+++ b/rust/taplo.toml
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[formatting]
+indent_string = '    '


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to