Skip to content

feat(Rust): add EdgeInfo support#837

Open
Sober7135 wants to merge 1 commit intoapache:mainfrom
Sober7135:832-rust-binding-add-edge-info
Open

feat(Rust): add EdgeInfo support#837
Sober7135 wants to merge 1 commit intoapache:mainfrom
Sober7135:832-rust-binding-add-edge-info

Conversation

@Sober7135
Copy link
Contributor

@Sober7135 Sober7135 commented Jan 30, 2026

Reason for this PR

#832 implement EdgeInfo binding for Rust

What changes are included in this PR?

This PR extends the Rust bindings to cover GraphAr edge metadata (EdgeInfo) and adjacency list metadata, and introduces a crate-wide error type to improve ergonomics and error propagation.
(following details are generated by AI )

rust/include/graphar_rs.h

  • Adds C++ API surface for edge metadata and adjacency lists:
    • create_edge_info, edge_info_save, edge_info_dump
    • new_adjacent_list_vec, push_adjacent_list
  • Introduces graphar::SharedAdjacentList and includes <cstddef> for completeness.

rust/src/error.rs (new)

  • Introduces crate::Error and crate::Result<T>:
    • Error::Cxx(cxx::Exception) for propagated C++ exceptions
    • Error::NonUtf8Path(PathBuf) for rejecting non-UTF8 filesystem paths
  • Adds unit tests for display/source behavior and conversion.

rust/src/lib.rs

  • Exposes pub mod error and re-exports Error/Result at the crate root.
  • Adds path_to_utf8_str(&Path) -> crate::Result<&str> used by save APIs.
  • Removes the previous cxx_string_to_string helper in favor of .to_string().

rust/src/ffi.rs

  • Adds SharedAdjacentList as an opaque cxx::ExternType.
  • Extends the cxx::bridge with:
    • AdjListType (GraphAr AdjListType bit flags)
    • AdjacentList bindings (CreateAdjacentList, getters)
    • AdjacentListVector helpers (new_adjacent_list_vec, push_adjacent_list)
    • EdgeInfo bindings (getters, property group accessors, create_edge_info, save, dump)

rust/src/graphar_rs.cc

  • Implements create_edge_info with explicit validation and null checks.
  • Adds AdjacentListVector constructor/push helpers exposed to Rust via cxx.
  • Implements edge_info_save and edge_info_dump with error propagation via exceptions.

rust/src/info/mod.rs

  • Registers new modules: adjacent_list, edge_info.
  • Re-exports:
    • AdjListType
    • AdjacentList, AdjacentListVector
    • EdgeInfo, EdgeInfoBuilder

rust/src/info/adjacent_list.rs (new)

  • Adds Rust-side wrappers for adjacency list metadata:
    • AdjacentList::new, getters (ty, file_type, prefix)
    • AdjacentListVector wrapper with new, push, and borrowing helpers
  • Includes unit tests for roundtrip getters, default prefix behavior, and vector push.

rust/src/info/edge_info.rs (new)

  • Adds Rust-side wrappers for edge metadata:
    • EdgeInfo getters (types, chunk sizes, prefix, directed, version)
    • adjacency list queries (has_adjacent_list_type, adjacent_list)
    • property group APIs (count, C++-borrowed view, iterator, lookups)
    • save/dump
  • Introduces EdgeInfoBuilder to reduce constructor argument noise.
  • Includes extensive unit tests for:
    • builder ergonomics and helper methods
    • error paths (invalid args, empty adjacency list vector)
    • dump/save behavior and non-UTF8 path rejection

rust/src/info/version.rs

  • Changes InfoVersion::new to return crate::Result<Self> to align with the new crate-wide error type.
  • Minor doc wording update.

rust/src/info/vertex_info.rs

  • Builder API adjustments:
    • VertexInfo::builder(type, chunk_size) no longer takes property_groups as a required argument.
    • Adds builder setters/helpers: push_property_group and property_groups.
  • Tightens several APIs from AsRef<[u8]> to AsRef<str> for type/prefix/property name inputs.
  • Changes save to require a UTF-8 path (returns Error::NonUtf8Path for non-UTF8 paths on Unix).
  • Updates and expands unit tests to reflect new builder behavior and path semantics.

rust/src/property.rs

  • Refactors PropertyVec and PropertyGroupVector wrappers:
    • Removes DerefMut usage and introduces explicit borrowing helpers (as_ref, pin_mut) for mutating C++ vectors.
  • Changes PropertyGroup::new prefix input from bytes to AsRef<str>.
  • Updates unit tests to match the new borrowing patterns and APIs.

Are these changes tested?

Yes

Are there any user-facing changes?

Yes

@Sober7135 Sober7135 force-pushed the 832-rust-binding-add-edge-info branch from 1ab9e83 to 4f4acd3 Compare January 30, 2026 20:02
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 98.60335% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.21%. Comparing base (878aa5c) to head (4f4acd3).

Files with missing lines Patch % Lines
rust/src/info/edge_info.rs 98.68% 6 Missing ⚠️
rust/src/error.rs 93.75% 2 Missing ⚠️
rust/src/info/vertex_info.rs 97.18% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #837      +/-   ##
============================================
+ Coverage     79.05%   80.21%   +1.15%     
  Complexity      615      615              
============================================
  Files            90       93       +3     
  Lines          9649    10265     +616     
  Branches       1047     1047              
============================================
+ Hits           7628     8234     +606     
- Misses         1781     1791      +10     
  Partials        240      240              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the Rust bindings for GraphAr to include edge metadata (EdgeInfo) and adjacency list metadata, completing the symmetry with the existing vertex metadata support. It also introduces a crate-wide error type to improve ergonomics and error propagation throughout the API.

Changes:

  • Introduces Error and Result types for consistent error handling across the crate
  • Adds Rust bindings for EdgeInfo and AdjacentList with builder pattern support
  • Refactors existing APIs (VertexInfo, property types) to use the new error types and improve consistency

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
rust/src/error.rs New error module with Error enum and Result type alias for crate-wide error handling
rust/src/lib.rs Exports error types and adds UTF-8 path validation helper
rust/src/ffi.rs Extends FFI bridge with EdgeInfo, AdjacentList, and AdjListType bindings
rust/include/graphar_rs.h C++ header declarations for edge info and adjacency list APIs
rust/src/graphar_rs.cc C++ implementation with validation for create_edge_info and related functions
rust/src/info/mod.rs Adds and re-exports new adjacency list and edge info modules
rust/src/info/adjacent_list.rs New wrapper for adjacency list metadata with comprehensive tests
rust/src/info/edge_info.rs New wrapper for edge metadata with builder pattern and extensive tests
rust/src/info/vertex_info.rs Updates builder API and error handling; removes Unix-specific path handling in favor of UTF-8 requirement
rust/src/info/version.rs Updates to use crate-wide Result type
rust/src/property.rs Refactors to remove DerefMut and add explicit borrowing helpers; tightens API constraints to use AsRef<str>

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@yangxk1 yangxk1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants