Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
fb1fd33
feat(capi): scaffold xet_capi crate with cbindgen header generation
assafvayner Jul 1, 2026
f2131f0
feat(capi): XetStatus/XetError with panic guard and mapping
assafvayner Jul 1, 2026
018286e
feat(capi): opaque handle helpers and XetBytes buffer
assafvayner Jul 1, 2026
b3547bc
feat(capi): XetOp handle-based polling primitive
assafvayner Jul 1, 2026
e2ec2bc
feat(capi): session lifecycle, XetAuthConfig, and shared string helpers
assafvayner Jul 1, 2026
55a1142
feat(capi): XetFileInfo and Sha256 policy mapping
assafvayner Jul 1, 2026
8cd849e
feat(capi): upload operations, result metadata, and flat progress/ded…
assafvayner Jul 1, 2026
0f658a8
feat(capi): streaming upload operations
assafvayner Jul 1, 2026
d6a3e97
feat(capi): file download group operations
assafvayner Jul 1, 2026
e98f2ac
feat(capi): stream download operations
assafvayner Jul 1, 2026
3a3774b
feat(capi): session builders for upload commit and download groups
assafvayner Jul 1, 2026
d98d496
feat(capi): commit/download report handles and accessors
assafvayner Jul 1, 2026
ebab5df
test(capi): assert committed hf_xet.h is up to date
assafvayner Jul 1, 2026
d7c0f64
test(capi): C smoke compile + end-to-end simulation round-trip
assafvayner Jul 1, 2026
0668f77
chore(capi): remove unused helper and finalize xet_capi
assafvayner Jul 1, 2026
2e7b554
fix(capi): emit all op take fns in header, guard against FFI panics, …
assafvayner Jul 1, 2026
da458ae
refactor(capi): make xet_op_take_* leave ownership with the caller
assafvayner Jul 1, 2026
984cb3d
docs(capi): add C, C++, Go/cgo, and Swift examples
assafvayner Jul 1, 2026
90a8490
gitignore
assafvayner Jul 1, 2026
3e12c13
feat(capi): add C++ wrapper skeleton with Exception, check, RAII Handle
assafvayner Jul 1, 2026
88aee5b
feat(capi): add Bytes and FileInfo C++ wrappers
assafvayner Jul 1, 2026
816a59c
feat(capi): add FileMetadata owned/borrowed C++ wrappers
assafvayner Jul 1, 2026
8e2bf31
feat(capi): add CommitReport and DownloadGroupReport C++ wrappers
assafvayner Jul 1, 2026
4511770
feat(capi): add Op C++ wrapper with wait and take_* helpers
assafvayner Jul 1, 2026
7db7e13
feat(capi): add AuthConfig C++ builder wrapping XetAuthConfig/XetHeader
assafvayner Jul 1, 2026
223812c
feat(capi): add upload-side C++ wrappers (FileUpload, StreamUpload, U…
assafvayner Jul 1, 2026
9e31bdc
feat(capi): add download-side C++ wrappers (FileDownload, DownloadGro…
assafvayner Jul 1, 2026
8365eff
feat(capi): add Session C++ wrapper with new_* builders
assafvayner Jul 1, 2026
3e7ff3c
refactor(capi): rewrite C++ example on the xet_session.hpp wrapper
assafvayner Jul 1, 2026
d104675
docs(capi): note take_bytes/take_chunk poll requirement and c_config …
assafvayner Jul 1, 2026
d5ad005
ci(capi): test the C API in CI
assafvayner Jul 8, 2026
4086555
feat(capi): add CMake integration and move C++ wrapper to include/
assafvayner Jul 8, 2026
5ce48cb
Merge remote-tracking branch 'origin' into assaf/c-api
assafvayner Jul 10, 2026
a0d7e4d
cargo.lock
assafvayner Jul 13, 2026
6bf17ac
docs(capi): document FFI surface, add Doxygen config, relocate C++ wr…
assafvayner Jul 14, 2026
c980194
refactor(capi): make upload finalize and commit blocking
assafvayner Jul 14, 2026
11ec630
refactor(capi): make stream upload write and finish blocking
assafvayner Jul 14, 2026
01b5c9c
refactor(capi): make download group finish blocking
assafvayner Jul 14, 2026
e8faecc
refactor(capi): remove xet_init_logging from C API
assafvayner Jul 14, 2026
832bd69
refactor(capi): make download stream next blocking
assafvayner Jul 15, 2026
a231abc
refactor(capi): remove XetOp poll-based async machinery
assafvayner Jul 15, 2026
af266a8
test(capi): poll progress from second thread during blocking download
assafvayner Jul 15, 2026
5e7b0f8
docs(capi): update C example for blocking API with progress thread
assafvayner Jul 15, 2026
fd36e91
docs(capi): update C++ wrapper and example for blocking API
assafvayner Jul 15, 2026
0d18412
docs(capi): update Go example for blocking API
assafvayner Jul 15, 2026
ffb1cfe
docs(capi): update Swift example and README for blocking API
assafvayner Jul 15, 2026
8001179
chore(capi): drop unused xet-runtime dep, update yanked spin to 0.9.9
assafvayner Jul 15, 2026
d15c8b5
docs(capi): add Zig example for blocking C API
assafvayner Jul 15, 2026
7ebc741
c api updates
assafvayner Jul 16, 2026
ce85eeb
Merge branch 'main' into assaf/c-api
assafvayner Aug 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,35 @@ jobs:
source .venv/bin/activate
pip install pytest
pytest hf_xet/tests/ -v
build_and_test-capi:
name: C API (xet_capi)
runs-on:
group: aws-general-8-plus
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: huggingface/hf-workflows/.github/actions/setup-hf-registry-proxies@21845492ef47d4e46b07a3b2a6e14fd4748c39cc # main
- name: Install Rust 1.94
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master
with:
toolchain: 1.94.1
- uses: ./.github/actions/cache-rust-build
- name: FFI tests (header up-to-date, ABI round-trip)
# Covers the Rust-side FFI suite: header freshness (cbindgen), smoke.c
# compilation against the committed header, and an end-to-end upload ->
# commit -> download round-trip over a local CAS (simulation feature, no
# network).
run: |
cargo test -p xet_capi --features simulation --verbose --no-fail-fast
- name: Link and run C smoke test against the built library
# The Rust c_smoke_compiles test only compiles the translation unit; here
# we link smoke.c against the actual cdylib and run it, exercising real
# ABI linkage end to end.
run: |
set -eux
cargo build -p xet_capi --release
cc xet_capi/tests/smoke.c -Ixet_capi/include -Ltarget/release -lxet_capi -o "$RUNNER_TEMP/xet_capi_smoke"
LD_LIBRARY_PATH=target/release "$RUNNER_TEMP/xet_capi_smoke"
build_and_test-wasm:
name: Build WASM
runs-on:
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ venv
**/*.env
.worktrees/
**/node_modules/

# Swift toolchain installer artifacts (swiftly)
/swiftly.pkg
/.swift-version

# Doxygen-generated API docs for xet_capi
xet_capi/docs/
90 changes: 90 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"xet_client",
"xet_data",
"xet_pkg",
"xet_capi",

# Top-level crates (not published as packages)
"git_xet",
Expand Down
78 changes: 78 additions & 0 deletions xet_capi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# CMake integration for the hf_xet C/C++ API.
#
# Consumers add this directory and link the imported `xet_capi` target:
#
# add_subdirectory(/path/to/xet-core/xet_capi xet_capi)
# target_link_libraries(my_target PRIVATE xet_capi)
#
# The target carries the include directory for `hf_xet.h` (C API). A
# header-only C++ wrapper (`xet_session.hpp`, requires C++17) lives alongside
# the C++ example in examples/cpp/.
#
# Requires a Rust toolchain; the library is built with `cargo build -p xet_capi`.
# Linking is static by default (set XET_CAPI_SHARED=ON for the shared library).
# CARGO_TARGET_DIR overrides are not supported; the workspace target directory
# is assumed to be <xet-core>/target.

cmake_minimum_required(VERSION 3.15)
project(xet_capi LANGUAGES C)

option(XET_CAPI_SHARED "Link the shared xet_capi library instead of the static one" OFF)

find_program(XET_CAPI_CARGO cargo REQUIRED)

set(XET_CAPI_CRATE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(XET_CAPI_TARGET_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../target)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(XET_CAPI_PROFILE debug)
set(XET_CAPI_CARGO_FLAGS "")
else()
set(XET_CAPI_PROFILE release)
set(XET_CAPI_CARGO_FLAGS --release)
endif()

if(XET_CAPI_SHARED)
set(XET_CAPI_LIB_FILE
${XET_CAPI_TARGET_DIR}/${XET_CAPI_PROFILE}/${CMAKE_SHARED_LIBRARY_PREFIX}xet_capi${CMAKE_SHARED_LIBRARY_SUFFIX})
else()
set(XET_CAPI_LIB_FILE
${XET_CAPI_TARGET_DIR}/${XET_CAPI_PROFILE}/${CMAKE_STATIC_LIBRARY_PREFIX}xet_capi${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()

# cargo tracks Rust source changes itself; run it on every build (no-op when fresh).
add_custom_target(xet_capi_cargo
COMMAND ${XET_CAPI_CARGO} build -p xet_capi ${XET_CAPI_CARGO_FLAGS}
WORKING_DIRECTORY ${XET_CAPI_CRATE_DIR}
BYPRODUCTS ${XET_CAPI_LIB_FILE}
VERBATIM USES_TERMINAL
COMMENT "Building xet_capi with cargo (${XET_CAPI_PROFILE})"
)

if(XET_CAPI_SHARED)
add_library(xet_capi SHARED IMPORTED GLOBAL)
else()
add_library(xet_capi STATIC IMPORTED GLOBAL)
endif()
add_dependencies(xet_capi xet_capi_cargo)

set_target_properties(xet_capi PROPERTIES
IMPORTED_LOCATION ${XET_CAPI_LIB_FILE}
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/include
)

# System libraries required by the Rust static library
# (from `cargo rustc -p xet_capi --release -- --print native-static-libs`).
if(NOT XET_CAPI_SHARED)
if(APPLE)
set_property(TARGET xet_capi APPEND PROPERTY INTERFACE_LINK_LIBRARIES
"-framework Security" "-framework CoreFoundation" "-framework SystemConfiguration"
"-framework IOKit" objc iconv)
elseif(WIN32)
set_property(TARGET xet_capi APPEND PROPERTY INTERFACE_LINK_LIBRARIES
ws2_32 userenv bcrypt ntdll crypt32 secur32 ncrypt)
elseif(UNIX)
set_property(TARGET xet_capi APPEND PROPERTY INTERFACE_LINK_LIBRARIES
pthread dl m)
endif()
endif()
30 changes: 30 additions & 0 deletions xet_capi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "xet_capi"
version.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
description = "C ABI bindings for the Hugging Face Xet client (hf-xet)."

[lib]
name = "xet_capi"
crate-type = ["cdylib", "staticlib", "rlib"]

[dependencies]
xet = { package = "hf-xet", version = "1.5.2", path = "../xet_pkg" }
bytes = { workspace = true }

[build-dependencies]
cbindgen = "0.29"

[dev-dependencies]
cbindgen = "0.29"
cc = "1"
tempfile = { workspace = true }

[features]
simulation = ["xet/simulation"]

[package.metadata.cargo-machete]
ignored = ["xet"]
Loading
Loading