Sober7135 opened a new pull request, #837: URL: https://github.com/apache/incubator-graphar/pull/837
<!-- Thanks for contributing to GraphAr. If this is your first pull request you can find detailed information on [CONTRIBUTING.md](https://github.com/apache/graphar/blob/main/CONTRIBUTING.md) The Apache GraphAr (incubating) community has restrictions on the naming of pr title. You can find instructions in [CONTRIBUTING.md](https://github.com/apache/graphar/blob/main/CONTRIBUTING.md#title) too. --> ### Reason for this PR <!-- Why are you proposing this change? If this is already tracked in an issue, please link to the issue here. Explaining clearly why this change is beneficial is important for the reviewers to understand the context. --> #832 implement `EdgeInfo` binding for Rust ### What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes 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. ( details is 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? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Yes ### Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> Yes <!-- If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking. --> <!-- **BREAKING CHANGE: <description>** --> <!-- Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious. --> <!-- **Critical Fix: <description>** --> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
