Skip to content

Commit

Permalink
Merge pull request #2962 from kuzudb/rust-version-api
Browse files Browse the repository at this point in the history
Expose kuzu version and storage version in the rust API
  • Loading branch information
ray6080 committed Feb 28, 2024
2 parents ea4b95b + f35bfc6 commit d661d99
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/rust_api/include/kuzu_rs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "common/types/value/rel.h"
#include "common/types/value/value.h"
#include "main/kuzu.h"
#include "storage/storage_info.h"
#else
#include <kuzu.hpp>
#endif
Expand Down Expand Up @@ -208,4 +209,8 @@ inline rust::Vec<uint8_t> get_blob_from_bytes(const rust::Vec<uint8_t>& value) {
return result;
}

inline kuzu::storage::storage_version_t get_storage_version() {
return kuzu::storage::StorageVersionInfo::getStorageVersion();
}

} // namespace kuzu_rs
5 changes: 5 additions & 0 deletions tools/rust_api/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,9 @@ pub(crate) mod ffi {

fn get_blob_from_bytes(value: &Vec<u8>) -> Vec<u8>;
}

#[namespace = "kuzu_rs"]
unsafe extern "C++" {
fn get_storage_version() -> u64;
}
}
7 changes: 7 additions & 0 deletions tools/rust_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,10 @@ pub use value::{InternalID, NodeVal, RelVal, Value};

#[cfg(feature = "arrow")]
pub use query_result::ArrowIterator;

/// The version of the Kùzu crate as reported by Cargo's CARGO_PKG_VERSION environment variable
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
/// Returns the storage version of the Kùzu library
pub fn get_storage_version() -> u64 {
crate::ffi::ffi::get_storage_version()
}

0 comments on commit d661d99

Please sign in to comment.