This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new b93240a6e3 feat: make FFI structs fields `pub` (#9772)
b93240a6e3 is described below
commit b93240a6e3a49866b52eb9ddaf95b513f57fc1f3
Author: Eshed Schacham <[email protected]>
AuthorDate: Wed Apr 22 20:12:37 2026 +0200
feat: make FFI structs fields `pub` (#9772)
# Which issue does this PR close?
- Closes #9771 .
# Are these changes tested?
No need for additional tests.
# Are there any user-facing changes?
New fields are exposed.
---
arrow-data/src/ffi.rs | 42 ++++++++++++++++++++++++++----------------
arrow-schema/src/ffi.rs | 29 +++++++++++++++++++----------
2 files changed, 45 insertions(+), 26 deletions(-)
diff --git a/arrow-data/src/ffi.rs b/arrow-data/src/ffi.rs
index 408dfbaac9..80ccee6c8a 100644
--- a/arrow-data/src/ffi.rs
+++ b/arrow-data/src/ffi.rs
@@ -25,7 +25,7 @@ use arrow_schema::DataType;
use std::ffi::c_void;
/// ABI-compatible struct for ArrowArray from C Data Interface
-/// See
<https://arrow.apache.org/docs/format/CDataInterface.html#structure-definitions>
+/// See
<https://arrow.apache.org/docs/format/CDataInterface.html#the-arrowarray-structure>
///
/// ```
/// # use arrow_data::ArrayData;
@@ -37,21 +37,31 @@ use std::ffi::c_void;
#[repr(C)]
#[derive(Debug)]
pub struct FFI_ArrowArray {
- length: i64,
- null_count: i64,
- offset: i64,
- n_buffers: i64,
- n_children: i64,
- buffers: *mut *const c_void,
- children: *mut *mut FFI_ArrowArray,
- dictionary: *mut FFI_ArrowArray,
- release: Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowArray)>,
- // When exported, this MUST contain everything that is owned by this array.
- // for example, any buffer pointed to in `buffers` must be here, as well
- // as the `buffers` pointer itself.
- // In other words, everything in [FFI_ArrowArray] must be owned by
- // `private_data` and can assume that they do not outlive `private_data`.
- private_data: *mut c_void,
+ /// Logical length of the array
+ pub length: i64,
+ /// Number of null items in the array
+ pub null_count: i64,
+ /// logical offset inside the array
+ pub offset: i64,
+ /// Number of physical buffers backing this array
+ pub n_buffers: i64,
+ /// Number of children this array has
+ pub n_children: i64,
+ /// C array of pointers to the start of each physical buffer backing this
array
+ pub buffers: *mut *const c_void,
+ /// C array of pointers to each child array of this array
+ pub children: *mut *mut FFI_ArrowArray,
+ /// Pointer to the underlying array of dictionary values
+ pub dictionary: *mut FFI_ArrowArray,
+ /// Pointer to a producer-provided release callback
+ pub release: Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowArray)>,
+ /// Opaque pointer to producer-provided private data
+ /// When exported, this MUST contain everything that is owned by this
array.
+ /// For example, any buffer pointed to in `buffers` must be here, as well
+ /// as the `buffers` pointer itself.
+ /// In other words, everything in [FFI_ArrowArray] must be owned by
+ /// `private_data` and can assume that they do not outlive `private_data`.
+ pub private_data: *mut c_void,
}
impl Drop for FFI_ArrowArray {
diff --git a/arrow-schema/src/ffi.rs b/arrow-schema/src/ffi.rs
index 46c622a6d3..c2df07376f 100644
--- a/arrow-schema/src/ffi.rs
+++ b/arrow-schema/src/ffi.rs
@@ -61,7 +61,7 @@ bitflags! {
}
/// ABI-compatible struct for `ArrowSchema` from C Data Interface
-/// See
<https://arrow.apache.org/docs/format/CDataInterface.html#structure-definitions>
+/// See
<https://arrow.apache.org/docs/format/CDataInterface.html#the-arrowschema-structure>
///
/// ```
/// # use arrow_schema::DataType;
@@ -75,16 +75,25 @@ bitflags! {
#[derive(Debug)]
#[allow(non_camel_case_types)]
pub struct FFI_ArrowSchema {
- format: *const c_char,
- name: *const c_char,
- metadata: *const c_char,
+ /// Null-terminated, UTF8-encoded string describing the data type
+ pub format: *const c_char,
+ /// Null-terminated, UTF8-encoded string of the field or array name
+ pub name: *const c_char,
+ /// Binary string describing the type’s metadata
+ pub metadata: *const c_char,
+ /// A bitfield of flags enriching the type description
/// Refer to [Arrow
Flags](https://arrow.apache.org/docs/format/CDataInterface.html#c.ArrowSchema.flags)
- flags: i64,
- n_children: i64,
- children: *mut *mut FFI_ArrowSchema,
- dictionary: *mut FFI_ArrowSchema,
- release: Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowSchema)>,
- private_data: *mut c_void,
+ pub flags: i64,
+ /// The number of children this type has
+ pub n_children: i64,
+ /// C array of pointers to each child type of this type
+ pub children: *mut *mut FFI_ArrowSchema,
+ /// Pointer to the type of dictionary values
+ pub dictionary: *mut FFI_ArrowSchema,
+ /// Pointer to a producer-provided release callback
+ pub release: Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowSchema)>,
+ /// Opaque pointer to producer-provided private data
+ pub private_data: *mut c_void,
}
struct SchemaPrivateData {