### Build Project with Tests and Examples (Linux/macOS) Source: https://github.com/questdb/c-questdb-client/blob/main/doc/BUILD.md Configures and builds the project, including tests and examples by setting QUESTDB_TESTS_AND_EXAMPLES to ON. ```bash $ cmake -S . -B build \ -DCMAKE_BUILD_TYPE=Release \ -DQUESTDB_TESTS_AND_EXAMPLES=ON $ cmake --build build ``` -------------------------------- ### Install Corrosion from Source Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/doc/src/setup_corrosion.md Build and install Corrosion from its source code. This method pre-builds native tooling for older CMake versions and installs Corrosion's CMake files. Specify CMAKE_INSTALL_PREFIX for a custom installation directory. ```bash git clone https://github.com/corrosion-rs/corrosion.git # Optionally, specify -DCMAKE_INSTALL_PREFIX= to specify a # custom installation directory cmake -Scorrosion -Bbuild -DCMAKE_BUILD_TYPE=Release cmake --build build --config Release # This next step may require sudo or admin privileges if you're installing to a system location, # which is the default. cmake --install build --config Release ``` -------------------------------- ### Compile C Example with QuestDB Client Source: https://github.com/questdb/c-questdb-client/blob/main/CMakeLists.txt Compiles a C example executable and links it against the QuestDB client library. ```cmake function(compile_example TARGET_NAME) list(POP_FRONT ARGV) add_executable( ${TARGET_NAME} ${ARGV}) target_link_libraries( ${TARGET_NAME} questdb_client) endfunction() ``` -------------------------------- ### Compile C++ Example with QuestDB Client Source: https://github.com/questdb/c-questdb-client/blob/main/CMakeLists.txt Compiles a C++ example executable and links it against the QuestDB client library. ```cmake if (QUESTDB_TESTS_AND_EXAMPLES) compile_example( line_sender_c_example examples/concat.c examples/line_sender_c_example.c) compile_example( line_sender_c_example_array_byte_strides examples/concat.c examples/line_sender_c_example_array_byte_strides.c) compile_example( line_sender_c_example_array_elem_strides examples/concat.c examples/line_sender_c_example_array_elem_strides.c) compile_example( line_sender_c_example_array_c_major examples/concat.c examples/line_sender_c_example_array_c_major.c) compile_example( line_sender_c_example_auth examples/concat.c examples/line_sender_c_example_auth.c) compile_example( line_sender_c_example_tls_ca examples/concat.c examples/line_sender_c_example_tls_ca.c) compile_example( line_sender_c_example_auth_tls examples/concat.c examples/line_sender_c_example_auth_tls.c) compile_example( line_sender_c_example_http examples/concat.c examples/line_sender_c_example_http.c) compile_example( line_sender_c_example_from_conf examples/line_sender_c_example_from_conf.c) compile_example( line_sender_c_example_from_env examples/line_sender_c_example_from_env.c) compile_example( line_sender_c_example_qwpudp examples/line_sender_c_example_qwpudp.c) compile_example( line_sender_c_example_qwpudp_batch examples/line_sender_c_example_qwpudp_batch.c) compile_example( line_sender_c_example_decimal_binary examples/concat.c examples/line_sender_c_example_decimal_binary.c) compile_example( line_sender_cpp_example examples/line_sender_cpp_example.cpp) compile_example( line_sender_cpp_example_array_byte_strides examples/line_sender_cpp_example_array_byte_strides.cpp) compile_example( line_sender_cpp_example_array_elem_strides examples/line_sender_cpp_example_array_elem_strides.cpp) compile_example( line_sender_cpp_example_array_custom examples/line_sender_cpp_example_array_custom.cpp) compile_example( line_sender_cpp_example_auth examples/line_sender_cpp_example_auth.cpp) compile_example( line_sender_cpp_example_array_c_major examples/line_sender_cpp_example_array_c_major.cpp) compile_example( line_sender_cpp_example_tls_ca examples/line_sender_cpp_example_tls_ca.cpp) compile_example( line_sender_cpp_example_auth_tls examples/line_sender_cpp_example_auth_tls.cpp) compile_example( line_sender_cpp_example_http examples/line_sender_cpp_example_http.cpp) compile_example( line_sender_cpp_example_from_conf examples/line_sender_cpp_example_from_conf.cpp) compile_example( line_sender_cpp_example_from_env examples/line_sender_cpp_example_from_env.cpp) compile_example( line_sender_cpp_example_qwpudp examples/line_sender_cpp_example_qwpudp.cpp) compile_example( line_sender_cpp_example_qwpudp_batch examples/line_sender_cpp_example_qwpudp_batch.cpp) compile_example( line_sender_cpp_example_decimal_custom examples/line_sender_cpp_example_decimal_custom.cpp) compile_example( line_sender_cpp_example_decimal_binary examples/line_sender_cpp_example_decimal_binary.cpp) compile_example( line_reader_c_example_from_conf examples/line_reader_c_example_from_conf.c) compile_example( line_reader_cpp_example_from_conf examples/line_reader_cpp_example_from_conf.cpp) compile_example( line_reader_c_example_with_binds examples/line_reader_c_example_with_binds.c) compile_example( line_reader_cpp_example_with_binds examples/line_reader_cpp_example_with_binds.cpp) compile_example( line_reader_cpp_example_columns examples/line_reader_cpp_example_columns.cpp) compile_example( line_reader_c_example_columns examples/line_reader_c_example_columns.c) # Include Rust tests as part of the tests run add_test( NAME rust_tests WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/questdb-rs COMMAND cargo test --features insecure-skip-verify -- --nocapture) endif() ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/cxxbridge/cxxbridge_cpp2rust/CMakeLists.txt Sets up the minimum CMake version, project name, and C++ standard. Includes a common test header. ```cmake cmake_minimum_required(VERSION 3.15) project(test_project VERSION 0.1.0 LANGUAGES CXX) include(../../test_header.cmake) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED 1) ``` -------------------------------- ### Install Corrosion Test Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/CMakeLists.txt Adds a test to perform the installation of Corrosion after it has been built. This command executes the install step. ```cmake add_test(NAME "install_corrosion_install" COMMAND ${CMAKE_COMMAND} --install "${CMAKE_CURRENT_BINARY_DIR}/build-corrosion" --config Release ) ``` -------------------------------- ### Set Properties for Install Corrosion Tests Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/CMakeLists.txt Sets properties for the Corrosion installation tests, including fixtures for setup and requirements between test stages. ```cmake set_tests_properties("install_corrosion_configure" PROPERTIES FIXTURES_SETUP "fixture_corrosion_configure") set_tests_properties("install_corrosion_build" PROPERTIES FIXTURES_SETUP "fixture_corrosion_build") set_tests_properties("install_corrosion_build" PROPERTIES FIXTURES_REQUIRED "fixture_corrosion_configure") set_tests_properties("install_corrosion_install" PROPERTIES FIXTURES_REQUIRED "fixture_corrosion_build") set_tests_properties("install_corrosion_install" PROPERTIES FIXTURES_SETUP "fixture_corrosion_install") ``` -------------------------------- ### Install Cross-Compiler for PowerPC on Linux Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/doc/src/usage.md On Ubuntu, install the necessary cross-compiler for 64-bit Little-Endian PowerPC Little-Endian using apt-get. ```bash sudo apt install g++-powerpc64le-linux-gnu ``` -------------------------------- ### Install Corrosion to Test Directory Option Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/CMakeLists.txt Enables installing Corrosion to a test directory for tests to use the installed version. Defaults to OFF. ```cmake option(CORROSION_TESTS_INSTALL_CORROSION "Install Corrosion to a test directory and let tests use the installed Corrosion" OFF) ``` -------------------------------- ### Build Corrosion Installation Test Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/CMakeLists.txt Adds a test to build the Corrosion installation. This command executes the build process for the configured installation. ```cmake add_test(NAME "install_corrosion_build" COMMAND ${CMAKE_COMMAND} --build "${CMAKE_CURRENT_BINARY_DIR}/build-corrosion" --config Release ) ``` -------------------------------- ### Connect to QuestDB using Configuration Source: https://github.com/questdb/c-questdb-client/blob/main/doc/CPP.md Establishes a connection to QuestDB using configuration options, such as address and port. This is a common starting point for sending data. ```cpp #include ... auto sender = questdb::ingress::line_sender::from_conf( "http::addr=localhost:9000;" ); ``` -------------------------------- ### Install Rust Target Standard Library Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/doc/src/usage.md Use rustup to install the standard library for a specific Rust target triple, which is necessary for cross-compiling. ```bash rustup target add ``` -------------------------------- ### Build and Test C/C++ Components Source: https://github.com/questdb/c-questdb-client/blob/main/CONTRIBUTING.md Configure, build, and test the C/C++ components using CMake. The QUESTDB_TESTS_AND_EXAMPLES flag enables relevant tests and examples. ```sh cmake -S . -B build -DQUESTDB_TESTS_AND_EXAMPLES=ON cmake --build build ctest --test-dir build ``` -------------------------------- ### Test Install Path Variable Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/CMakeLists.txt Sets the installation path for tests to a subdirectory within the current binary directory. ```cmake set(test_install_path "${CMAKE_CURRENT_BINARY_DIR}/test-install-corrosion") ``` -------------------------------- ### Configure Corrosion Installation Test Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/CMakeLists.txt Adds a test to configure the Corrosion installation process. It sets up the source and build directories, specifies build type, generator, and install prefix. ```cmake add_test(NAME "install_corrosion_configure" COMMAND ${CMAKE_COMMAND} -S "${CMAKE_CURRENT_SOURCE_DIR}/.." -B "${CMAKE_CURRENT_BINARY_DIR}/build-corrosion" -DCORROSION_VERBOSE_OUTPUT=ON -DCORROSION_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -G${CMAKE_GENERATOR} "-DCMAKE_INSTALL_PREFIX=${test_install_path}" ) ``` -------------------------------- ### Sync with Remote Repository Source: https://github.com/questdb/c-questdb-client/blob/main/doc/RELEASING.md Ensure your local main branch is up-to-date with the remote repository before starting the release process. ```bash git switch main git pull git status ``` -------------------------------- ### Ingesting Trade Data with QuestDB Rust Client Source: https://github.com/questdb/c-questdb-client/blob/main/questdb-rs/src/ingress/mod.md Demonstrates how to configure a sender, populate a buffer with trade data including symbols, price, amount, and timestamp, and then flush the buffer to QuestDB. This example uses the HTTP transport. ```rust use questdb:: Result, ingress:: Sender, Buffer, TimestampNanos; fn main() -> Result<()> { let mut sender = Sender::from_conf("http::addr=localhost:9000;")?; let mut buffer = sender.new_buffer(); buffer .table("trades")?; .symbol("symbol", "ETH-USD")?; .symbol("side", "sell")?; .column_f64("price", 2615.54)?; .column_f64("amount", 0.00044)?; .at(TimestampNanos::now())?; sender.flush(&mut buffer)?; Ok(()) } ``` -------------------------------- ### Install Corrosion via Homebrew Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/doc/src/setup_corrosion.md Install Corrosion using the Homebrew package manager. Note that this package is community-maintained and minor version bumps may contain breaking changes before version 1.0. ```bash brew install corrosion ``` -------------------------------- ### Set Test Properties for Output Directory Build Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/output directory/CMakeLists.txt Configures properties for the 'output_directory_build' test, including setting up a fixture and optionally requiring a Corrosion installation fixture if Corrosion tests are installed. ```cmake set_tests_properties("output_directory_build" PROPERTIES FIXTURES_SETUP "build_fixture_output_directory") if(CORROSION_TESTS_INSTALL_CORROSION) set_tests_properties("output_directory_build" PROPERTIES FIXTURES_REQUIRED "fixture_corrosion_install") endif() ``` -------------------------------- ### Find Installed Corrosion Package Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/doc/src/setup_corrosion.md Once Corrosion is installed and its directory is in your PATH or CMAKE_PREFIX_PATH, find and use it in your CMake project. ```cmake find_package(Corrosion REQUIRED) ``` -------------------------------- ### Clean Build Directory Source: https://github.com/questdb/c-questdb-client/blob/main/doc/BUILD.md Removes the build directory to clean the project. Use this command to start a fresh build. ```bash $ rm -fR build # or your otherwise selected CMake build directory. ``` -------------------------------- ### Update Version in Codebase Source: https://github.com/questdb/c-questdb-client/blob/main/doc/RELEASING.md Use `bump-my-version` to replace all occurrences of the current version with the new version in the codebase. Ensure `uv` and `bump-my-version` are installed first. ```console bump-my-version replace --new-version NEW_VERSION ``` -------------------------------- ### C QuestDB Client Error Handling Example Source: https://github.com/questdb/c-questdb-client/blob/main/doc/C.md Demonstrates how to check for errors after calling `line_sender_flush` and perform necessary cleanup. Ensure to free the error object and close the sender on failure. ```c line_sender* sender = ...; line_sender_error* err = NULL; if (!line_sender_flush(sender, &err)) { size_t msg_len = 0; const char* msg = line_sender_error_msg(err, &msg_len); fprintf(stderr, "Could not set table name: %.*s", (int)msg_len, msg); // Clean-up line_sender_error_free(err); line_sender_close(sender); return; } ``` -------------------------------- ### Add Custom Build Command to Copy Executable Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/output directory/output directory/CMakeLists.txt Adds a custom command to be executed after a target is built. This example copies the built executable to a different directory if it differs. ```cmake add_custom_command(TARGET cargo-build_rust_bin1 POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/another_dir" COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "${CMAKE_CURRENT_BINARY_DIR}/another_dir/moved_bin" ) ``` -------------------------------- ### Configure MacOS Shared Library Install Name and SONAME Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/doc/src/common_issues.md Use these CMake commands to set the install_name and SONAME for shared libraries on MacOS, ensuring proper linking. This is crucial when dealing with `ccdylibs` and avoiding hardcoded build-directory references. ```cmake corrosion_add_target_local_rustflags(your_crate -Clink-arg=-Wl,-install_name,@rpath/libyour_crate.dylib,-current_version,${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR},-compatibility_version,${PROJECT_VERSION_MAJOR}.0) set_target_properties(your_crate-shared PROPERTIES IMPORTED_NO_SONAME 0) set_target_properties(your_crate-shared PROPERTIES IMPORTED_SONAME libyour_crate.dylib) ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/find_rust/find_rust/CMakeLists.txt Specifies the minimum required CMake version and defines the project name. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required(VERSION 3.15) project(FindRust LANGUAGES CXX) ``` -------------------------------- ### Configure and Build Project (Linux/macOS) Source: https://github.com/questdb/c-questdb-client/blob/main/doc/BUILD.md Configures the build using CMake and then builds the project. Use 'Release' for optimized builds or 'Debug' for debugging. ```bash $ cmake -S . -B build \ -DCMAKE_BUILD_TYPE=Release # .. or -DCMAKE_BUILD_TYPE=Debug for debugging. $ cmake --build build ``` -------------------------------- ### Configure and Build for System Testing (Linux/macOS) Source: https://github.com/questdb/c-questdb-client/blob/main/doc/BUILD.md Configures the build with system testing enabled, then builds and runs tests. Requires Java 11 and Python 3.8+. ```bash $ cmake -S . -B build -DQUESTDB_SYSTEM_TESTING=ON $ (cd build && make && ctest) ``` -------------------------------- ### Cleanup Installed Corrosion Directory Test Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/CMakeLists.txt Adds a test to clean up the installed Corrosion directory after tests. This removes the test installation path. ```cmake add_test(NAME "install_corrosion_cleanup" COMMAND "${CMAKE_COMMAND}" -E remove_directory "${test_install_path}") set_tests_properties("install_corrosion_cleanup" PROPERTIES FIXTURES_CLEANUP "fixture_corrosion_configure;fixture_corrosion_build;fixture_corrosion_install" ) ``` -------------------------------- ### Cleanup Build Directory for Corrosion Installation Test Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/CMakeLists.txt Adds a test to clean up the build directory used for Corrosion installation. This removes the build directory after the installation tests. ```cmake add_test(NAME "install_corrosion_build_cleanup" COMMAND "${CMAKE_COMMAND}" -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/build-corrosion") set_tests_properties("install_corrosion_build_cleanup" PROPERTIES FIXTURES_CLEANUP "fixture_corrosion_configure;fixture_corrosion_build" ) ``` -------------------------------- ### Connect to QuestDB with Configuration Source: https://github.com/questdb/c-questdb-client/blob/main/doc/C.md Establishes a connection to QuestDB using a configuration string. Handles potential connection errors. ```c #include ... line_sender_utf8 conf = QDB_UTF8_LITERAL( "http::addr=localhost:9000;"); line_sender_error* err = NULL; line_sender* sender = sender = line_sender_from_conf(&err); if (!sender) { /* ... handle error ... */ } ``` -------------------------------- ### List Library Files Source: https://github.com/questdb/c-questdb-client/blob/main/doc/BUILD.md Lists the generated static and dynamic library files in the build directory. ```bash $ ls build/libquestdb_client.* build/libquestdb_client.a build/libquestdb_client.so ``` -------------------------------- ### Reproduce Live Server Tests Source: https://github.com/questdb/c-questdb-client/blob/main/CONTRIBUTING.md Update submodules, build the QuestDB server JAR, and run live server tests for the Rust components. This requires a local QuestDB server instance. ```sh git submodule update --init --recursive # build the jar under questdb/core/target/ — see questdb/README.md cd questdb-rs cargo test --features live-server-tests ``` -------------------------------- ### Run Unit Tests (Linux/macOS) Source: https://github.com/questdb/c-questdb-client/blob/main/doc/BUILD.md Navigates to the build directory and runs the unit tests using ctest. ```bash $ (cd build && ctest) ``` -------------------------------- ### Add c-questdb-client using git subtree Source: https://github.com/questdb/c-questdb-client/blob/main/doc/DEPENDENCY.md Use this command to initially add the c-questdb-client source code into your project's 'deps/c-questdb-client' directory. Replace 'CHOSEN_RELEASE_TAG' with the desired release tag. ```bash git subtree add --prefix deps/c-questdb-client https://github.com/questdb/c-questdb-client.git CHOSEN_RELEASE_TAG --squash ``` -------------------------------- ### CMake FetchContent Integration Source: https://github.com/questdb/c-questdb-client/blob/main/doc/DEPENDENCY.md Integrates the c-questdb-client library into a CMake project using FetchContent. Replace CHOSEN_RELEASE_TAG with a valid Git tag and update your_project_name. ```cmake # CMakeLists.txt cmake_minimum_required(VERSION 3.15.0) project(your_project_name VERSION 1.0.0) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) include(FetchContent) FetchContent_Declare( c_questdb_client_proj GIT_REPOSITORY https://github.com/questdb/c-questdb-client.git GIT_TAG CHOSEN_RELEASE_TAG) # CHANGE ME! FetchContent_MakeAvailable(c_questdb_client_proj) add_executable( main main.cpp) target_link_libraries( main questdb_client) ``` -------------------------------- ### Configure CMakeLists.txt to build with c-questdb-client Source: https://github.com/questdb/c-questdb-client/blob/main/doc/DEPENDENCY.md This CMake configuration adds the c-questdb-client subdirectory and links the 'questdb_client' target to your executable. Remember to update 'your_project_name'. ```cmake # CMakeLists.txt cmake_minimum_required(VERSION 3.15.0) project(your_project_name VERSION 1.0.0) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) add_subdirectory( deps/c-questdb-client EXCLUDE_FROM_ALL) add_executable( main main.cpp) target_link_libraries( main questdb_client) ``` -------------------------------- ### Configure System Tests Source: https://github.com/questdb/c-questdb-client/blob/main/CMakeLists.txt Configures system tests by finding Python 3 and Java 11, and adding a CTest for the system test script. Requires Java 11 and downloads the latest QuestDB instance. ```cmake option(QUESTDB_SYSTEM_TESTING "Run system tests" OFF) if(QUESTDB_SYSTEM_TESTING) find_package( Python3 REQUIRED COMPONENTS Interpreter) find_package( Java 11 REQUIRED) add_test( NAME system_test COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/system_test/test.py run -v) set_tests_properties( system_test PROPERTIES ENVIRONMENT BUILD_DIR_PATH=${CMAKE_BINARY_DIR}) endif(QUESTDB_SYSTEM_TESTING) ``` -------------------------------- ### Configure Test Directory and Compiler Variables Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/CMakeLists.txt Sets up the test directory and compiler-related variables. These are used to configure the build process for the Corrosion tests. ```cmake if(TST_TEST_SRC_DIR) set(test_dir "${TST_TEST_SRC_DIR}") else() set(test_dir "${test_name}") endif() if(CMAKE_C_COMPILER) set(TEST_C_COMPILER "C_COMPILER" "${CMAKE_C_COMPILER}") endif() if(CMAKE_CXX_COMPILER) set(TEST_CXX_COMPILER "CXX_COMPILER" "${CMAKE_CXX_COMPILER}") endif() if(CMAKE_GENERATOR_PLATFORM) set(TEST_GENERATOR_PLATFORM "GENERATOR_PLATFORM" "${CMAKE_GENERATOR_PLATFORM}") endif() if(CORROSION_GENERATOR_EXECUTABLE) # Mainly used in CI to build the native generator once and then reuse it for all tests set(TEST_GENERATOR_BIN EXTERNAL_CORROSION_GENERATOR "${CORROSION_GENERATOR_EXECUTABLE}") endif() if(CMAKE_CROSSCOMPILING) set(TEST_SYSTEM_NAME SYSTEM_NAME "${CMAKE_SYSTEM_NAME}") endif() ``` -------------------------------- ### Adding Global Rustflags to a Target Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/rustflags/rustflags/CMakeLists.txt Adds custom rustflags that will be applied to all Rust compilations for the specified target. This example demonstrates adding a configuration-based flag. ```cmake corrosion_add_target_rustflags(rustflag_test_lib --cfg=test_rustflag_cfg1="test_rustflag_cfg1_value") ``` -------------------------------- ### Add Corrosion and Import Rust Library with CMake Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/doc/src/quick_start.md Use FetchContent to download Corrosion and corrosion_import_crate to integrate a Rust library into your C++ executable. Ensure Rust toolchain is configured before FetchContent_MakeAvailable. ```cmake include(FetchContent) FetchContent_Declare( Corrosion GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git GIT_TAG v0.5 # Optionally specify a commit hash, version tag or branch here ) # Set any global configuration variables such as `Rust_TOOLCHAIN` before this line! FetchContent_MakeAvailable(Corrosion) # Import targets defined in a package or workspace manifest `Cargo.toml` file corrosion_import_crate(MANIFEST_PATH rust-lib/Cargo.toml) add_executable(your_cool_cpp_bin main.cpp) # In this example the the `Cargo.toml` file passed to `corrosion_import_crate` is assumed to have # defined a static (`staticlib`) or shared (`cdylib`) rust library with the name "rust-lib". # A target with the same name is now available in CMake and you can use it to link the rust library into # your C/C++ CMake target(s). target_link_libraries(your_cool_cpp_bin PUBLIC rust-lib) ``` -------------------------------- ### Test Header Contents Definition Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/CMakeLists.txt Defines CMake commands to be written to a test header file, used for configuring Corrosion as a subdirectory or finding an installed package. ```cmake set(test_header_contents "option(CORROSION_TESTS_FIND_CORROSION \"Use Corrosion as a subdirectory\" OFF)" "if (CORROSION_TESTS_FIND_CORROSION)" " set(CMAKE_PREFIX_PATH \"${test_install_path}\" CACHE INTERNAL \"\" FORCE)" " find_package(Corrosion REQUIRED PATHS \"${test_install_path}\" NO_CMAKE_SYSTEM_PATH)" "else()" " add_subdirectory(\"${CMAKE_CURRENT_SOURCE_DIR}/..\" corrosion)" "endif()" ) ``` -------------------------------- ### Define Rustup Proxy Assertion Function Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/find_rust/rustup_proxy/CMakeLists.txt Defines a CMake function to assert that a given executable path points to a valid Rustup installation by checking its version output. ```cmake function(_assert_is_rustup_proxy executable_path) execute_process( COMMAND ${CMAKE_COMMAND} -E env RUSTUP_FORCE_ARG0=rustup "${executable_path}" --version OUTPUT_VARIABLE _VERSION_RAW ERROR_VARIABLE _VERSION_STDERR RESULT_VARIABLE _VERSION_RESULT ) if(NOT _VERSION_RESULT EQUAL "0") message(FATAL_ERROR "`${executable_path} --version` failed with ${_VERSION_RESULT}\n" "stderr:\n${_VERSION_STDERR}" ) endif() if (NOT _VERSION_RAW MATCHES "rustup [0-9\\.]+") message(FATAL_ERROR "`${executable_path} --version` output does not match rustup: ${_VERSION_RAW}\n") endif() endfunction() ``` -------------------------------- ### Basic C++ Ingress Sender Source: https://github.com/questdb/c-questdb-client/blob/main/doc/DEPENDENCY.md A minimal C++ program demonstrating how to initialize the line sender to connect to QuestDB. Ensure QuestDB is running on localhost:9000. ```cpp // main.cpp #include int main() { auto sender = questdb::ingress::line_sender::from_conf( "http::addr=localhost:9000;"); return 0; } ``` -------------------------------- ### Add c-questdb-client using git submodule Source: https://github.com/questdb/c-questdb-client/blob/main/doc/DEPENDENCY.md These commands add the c-questdb-client as a git submodule and checkout a specific release tag. Ensure to commit the changes afterwards. ```bash git submodule add https://github.com/questdb/c-questdb-client.git deps/c-questdb-client cd deps/c-questdb-client git checkout tags/CHOSEN_RELEASE_TAG cd ../.. git add deps/c-questdb-client git commit -m "Added submodule: c-questdb-client @ CHOSEN_RELEASE_TAG" ``` -------------------------------- ### Linking Imported Rust Crates to C++ Executable Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/workspace/workspace/CMakeLists.txt After importing Rust crates, they can be linked to C++ targets using `target_link_libraries`. This example links `member1` and `member2` to an executable named `my_program`. ```cmake add_executable(my_program main.cpp) target_link_libraries(my_program PUBLIC member1 member2) ``` -------------------------------- ### Import Rust Crate into CMake Project Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/README.md This snippet demonstrates how to use CMake's FetchContent to download and integrate Corrosion, and then import Rust targets defined in a Cargo.toml manifest. It links the imported Rust library to a C++ executable. ```cmake include(FetchContent) FetchContent_Declare( Corrosion GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git GIT_TAG v0.5 # Optionally specify a commit hash, version tag or branch here ) FetchContent_MakeAvailable(Corrosion) # Import targets defined in a package or workspace manifest `Cargo.toml` file corrosion_import_crate(MANIFEST_PATH rust-lib/Cargo.toml) add_executable(your_cpp_bin main.cpp) target_link_libraries(your_cpp_bin PUBLIC rust-lib) ``` -------------------------------- ### HTTP Basic Authentication Configuration Source: https://github.com/questdb/c-questdb-client/blob/main/questdb-rs/src/ingress/mod.md Configure the sender for HTTP basic authentication. Provide both 'username' and 'password'. ```rust # use questdb::{ Result, ingress::Sender}; # fn main() -> Result<()> { let mut sender = Sender::from_conf( "https::addr=localhost:9000;username=testUser1;password=Yfym3fgMv0B9;" )?; # Ok(()) # } ``` -------------------------------- ### Check Dynamic Library Dependencies Source: https://github.com/questdb/c-questdb-client/blob/main/doc/BUILD.md Displays the dependencies of the dynamic library on Linux. ```bash $ ldd build/libquestdb_client.so linux-vdso.so.1 (0x00007ffddd344000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe61d252000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe61d22f000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe61d229000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe61d037000) /lib64/ld-linux-x86-64.so.2 (0x00007fe61d2ee000) ``` -------------------------------- ### Connecting to QuestDB Source: https://github.com/questdb/c-questdb-client/blob/main/doc/C.md Establishes a connection to the QuestDB server using configuration parameters. It supports various connection options including authentication and TLS, which can be configured via a connection string or programmatically. ```APIDOC ## Connecting to QuestDB ### Description Establishes a connection to the QuestDB server using configuration parameters. It supports various connection options including authentication and TLS, which can be configured via a connection string or programmatically. ### Function Signature `line_sender* sender = sender = line_sender_from_conf(&err);` ### Parameters - `conf` (line_sender_utf8): Configuration string for the sender. Example: `"http::addr=localhost:9000;"` - `err` (line_sender_error**): Pointer to an error object to capture connection errors. ### Request Example ```c #include line_sender_utf8 conf = QDB_UTF8_LITERAL("http::addr=localhost:9000;"); line_sender_error* err = NULL; line_sender* sender = sender = line_sender_from_conf(&err); if (!sender) { /* ... handle error ... */ } ``` ### Response - Returns a `line_sender` object on success. - Returns `NULL` on failure, with error details in the `err` parameter. ``` -------------------------------- ### Import Rust Crate with Features Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/features/features/CMakeLists.txt Import a Rust crate using `corrosion_import_crate`, specifying features and manifest path. Use `ALL_FEATURES` to enable all features or `FEATURES` for specific ones. ```cmake corrosion_import_crate(MANIFEST_PATH rust/Cargo.toml FEATURES thirdfeature ALL_FEATURES) ``` -------------------------------- ### CMakeLists.txt for Basic Corrosion Profiles Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/custom_profiles/basic_profiles/CMakeLists.txt This CMakeLists.txt file configures a C++ project to use Corrosion for Rust integration. It ensures the CARGO_PROFILE variable is set, imports a Rust crate with the specified profile, and links the C++ executable against the Rust library. ```cmake cmake_minimum_required(VERSION 3.15) project(test_project VERSION 0.1.0) include(../../test_header.cmake) if(NOT DEFINED CARGO_PROFILE) message(FATAL_ERROR "Test internal error. The test should be called with the CARGO_PROFILE parameter.") endif() corrosion_import_crate(MANIFEST_PATH rust/Cargo.toml PROFILE ${CARGO_PROFILE}) add_executable(${CARGO_PROFILE}_bin main.cpp) target_link_libraries(${CARGO_PROFILE}_bin PUBLIC cargo_profiles_lib) ``` -------------------------------- ### Update c-questdb-client using git subtree Source: https://github.com/questdb/c-questdb-client/blob/main/doc/DEPENDENCY.md Run this command to update the c-questdb-client to a newer or older release. Replace 'NEWLY_CHOSEN_RELEASE_TAG' with the target release tag. ```bash git subtree pull --prefix deps/c-questdb-client https://github.com/questdb/c-questdb-client.git NEWLY_CHOSEN_RELEASE_TAG --squash ``` -------------------------------- ### Include Corrosion using FetchContent Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/doc/src/setup_corrosion.md Use the FetchContent module to download and include Corrosion in your CMake project. This method is recommended for CMake versions 3.19 and newer. Ensure Rust toolchain configuration precedes this step. ```cmake include(FetchContent) FetchContent_Declare( Corrosion GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git GIT_TAG v0.5 # Optionally specify a commit hash, version tag or branch here ) # Set any global configuration variables such as `Rust_TOOLCHAIN` before this line! FetchContent_MakeAvailable(Corrosion) ``` -------------------------------- ### Setting Unique Names for Bins and Libs in Cargo.toml Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/RELEASES.md Illustrates how to set unique names for binaries and libraries within a Cargo project using the `name` field in `Cargo.toml`. ```toml [lib] name = "my_lib" [[bin]] name = "my_bin" path = "src/main.rs" ``` -------------------------------- ### Parse Target Triple with Custom OS Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/parse_target_triple/parse_target_triple/CMakeLists.txt Demonstrates parsing a target triple that includes a custom OS identifier. This tests the flexibility of the parsing logic for non-standard OS names. ```cmake _corrosion_parse_target_triple("../../blah/x86_64-custom_os.json" arch vendor os env) ``` -------------------------------- ### Import Crate with Features Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/cargo_flags/cargo_flags/CMakeLists.txt Import a Rust crate from a specified manifest path, enabling specific Cargo features. ```cmake corrosion_import_crate(MANIFEST_PATH rust/Cargo.toml FLAGS --features one) ``` -------------------------------- ### Add Corrosion CMake Library with Git Subtree Source: https://github.com/questdb/c-questdb-client/blob/main/doc/DEV_NOTES.md Use this command to add the Corrosion CMake library, which facilitates compiling Rust from C/C++ projects. Specify the desired version tag. ```bash git subtree add --prefix corrosion https://github.com/corrosion-rs/corrosion v0.4.3 --squash ``` -------------------------------- ### Import Rust Crate with Corrosion Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/cbindgen/rust2cpp/CMakeLists.txt Use Corrosion to import a Rust crate specified by its Cargo.toml manifest path. ```cmake corrosion_import_crate(MANIFEST_PATH rust/Cargo.toml) ``` -------------------------------- ### List Annotated Git Tags Source: https://github.com/questdb/c-questdb-client/blob/main/doc/DEPENDENCY.md Lists all annotated tags in the repository, sorted by creation date in descending order. Useful for identifying available releases. ```bash # Following a git clone of https://github.com/questdb/c-questdb-client.git git tag -n99 --sort=-creatordate ``` -------------------------------- ### Compile Unit Test Binary Source: https://github.com/questdb/c-questdb-client/blob/main/CMakeLists.txt Defines a CMake function to compile and link unit test executables against the questdb_client library. It also configures test properties and sanitizers. ```cmake function(compile_test TARGET_NAME) list(POP_FRONT ARGV) # compile_test add_executable( ${TARGET_NAME} ${ARGV}) target_link_libraries( ${TARGET_NAME} questdb_client) target_include_directories( ${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) set_compile_flags(${TARGET_NAME}) apply_sanitizers(${TARGET_NAME}) add_test( NAME ${TARGET_NAME} COMMAND ${TARGET_NAME}) if(QUESTDB_SANITIZE AND NOT MSVC) # Leak detection is off: the Rust library is not instrumented and # legitimately retains process-global allocations at exit, which # LSan cannot tell apart from an FFI leak without a suppression # file. ASan's use-after-free / out-of-bounds / double-free checks # stay active. set_tests_properties( ${TARGET_NAME} PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_leaks=0;UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1") endif() endfunction() compile_test( test_line_sender cpp_test/mock_server.cpp cpp_test/test_line_sender.cpp) compile_test( test_line_reader cpp_test/test_line_reader.cpp) compile_test( line_reader_c_smoke cpp_test/smoke_line_reader.c) compile_test( test_line_reader_offline cpp_test/test_line_reader_offline.cpp) compile_test( test_line_reader_mock cpp_test/qwp_mock_server.cpp cpp_test/test_line_reader_mock.cpp) ``` -------------------------------- ### Link C++ Executable with Rust Library Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/cbindgen/rust2cpp/CMakeLists.txt Create a C++ executable and link it against the Rust library generated by Corrosion. ```cmake add_executable(cpp-exe main.cpp) set_property(TARGET cpp-exe PROPERTY CXX_STANDARD 11) target_link_libraries(cpp-exe PUBLIC rust_lib) ``` -------------------------------- ### Add Interoperability Tests with Git Subtree Source: https://github.com/questdb/c-questdb-client/blob/main/doc/DEV_NOTES.md Use this command to add shared test cases from another repository. The `--squash` option ensures a clean history. ```bash git subtree add --prefix questdb-rs/src/tests/interop https://github.com/questdb/questdb-client-test.git main --squash ``` -------------------------------- ### Writing Optional Data with Buffer API Source: https://github.com/questdb/c-questdb-client/blob/main/questdb-rs/src/ingress/mod.md Demonstrates how to use `_opt` variants of Buffer API methods to write optional data. If a value is `Some(v)`, it's written normally. If `None`, the column is skipped, representing a NULL value in QuestDB. ```rust use questdb::Result; use questdb::ingress::{Buffer, SenderBuilder, TimestampNanos}; fn main() -> Result<()> { let mut sender = SenderBuilder::from_conf("https::addr=localhost:9000;")?.build()?; let mut buffer = sender.new_buffer(); struct SensorData { sensor_id: Option, temperature: Option, humidity: Option, } let data = SensorData { sensor_id: Some("sensor-1".to_string()), temperature: Some(22.5), humidity: None }; buffer .table("sensors")? .symbol("location", "factory-1")? // Writes the sensor_id column if it's Some, otherwise skips it (stored as NULL in QuestDB) .symbol_opt("sensor_id", data.sensor_id.as_deref())? // Writes the temperature column .column_f64_opt("temperature", data.temperature)? // Silently skips the humidity column (stored as NULL in QuestDB) .column_f64_opt("humidity", data.humidity)? .at(TimestampNanos::now())?; Ok(()) } ``` -------------------------------- ### Publish Rust Crate (Dry Run) Source: https://github.com/questdb/c-questdb-client/blob/main/doc/RELEASING.md Perform a dry run of publishing the Rust crate to crates.io to verify the process without actually publishing. Requires your API token from crates.io. ```bash cd questdb-rs cargo publish --dry-run --token [your API token from crates.io] ``` -------------------------------- ### Configure v3 Extension for Server Certificate Source: https://github.com/questdb/c-questdb-client/blob/main/tls_certs/README.md Defines v3 extensions for the server certificate, including key usage and subject alternative names. ```bash $ vim v3.ext authorityKeyIdentifier=keyid,issuer basicConstraints=CA:FALSE keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment subjectAltName = @alt_names [alt_names] DNS.1 = localhost ``` -------------------------------- ### Passing Arguments to Cargo Build with VERBATIM Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/RELEASES.md Demonstrates how to pass arguments to `cargo build` using CMake's VERBATIM option. Previously required double escaping for certain flags like `cfg` options. ```cmake corrosion_add_target_rustflags(my_target --cfg=something=\"value\") ``` ```cmake corrosion_add_target_rustflags(my_target --cfg=something="value") ``` -------------------------------- ### Importing a Dynamic Library Crate Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/crate_type/crate_type/CMakeLists.txt Imports a Rust crate as a dynamic (cdylib) library. Use this for shared libraries that can be loaded at runtime. ```cmake corrosion_import_crate(MANIFEST_PATH proj2/Cargo.toml CRATE_TYPES cdylib FLAGS --crate-type=cdylib) ``` -------------------------------- ### Cross-Compile for ARM64 on Windows Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/doc/src/usage.md Cross-compile for ARM64 from any platform using the Visual Studio Generator by setting the -A architecture flag. Requires Rust 1.54+ for projects with build-scripts. ```bash cmake -S. -Bbuild-arm64 -A ARM64 cmake --build build-arm64 ``` -------------------------------- ### Add questdb-rs to Cargo Project Source: https://github.com/questdb/c-questdb-client/blob/main/questdb-rs/README.md Add the questdb-rs crate as a dependency to your Rust project using Cargo. ```bash cargo add questdb-rs ``` -------------------------------- ### Create Server CSR and Key Source: https://github.com/questdb/c-questdb-client/blob/main/tls_certs/README.md Generates a new 2048-bit RSA private key for the server and a Certificate Signing Request (CSR) using the specified configuration. ```bash $ openssl req -new -sha256 -nodes -out server.csr -newkey rsa:2048 -keyout server.key -config <( cat server_rootCA.csr.cnf ) Generating a 2048 bit RSA private key .................+++ .................................+++ writing new private key to 'server.key' ----- ``` -------------------------------- ### Test PDB File in Binary Output Directory Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/output directory/CMakeLists.txt Adds a CMake test to verify the existence of a binary's PDB file in its designated output directory. Requires the 'build_fixture_output_directory' fixture. ```cmake set(bin_pdb_name "rust_bin${rust_proj_suffix}.pdb") add_test(NAME output_directory_bin_pdb_${output_approach} COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/TestFileExists.cmake" "${CMAKE_CURRENT_BINARY_DIR}/build/${expected_bin_pdb_path}/${bin_pdb_name}" ) set_tests_properties("output_directory_bin_pdb_${output_approach}" PROPERTIES FIXTURES_REQUIRED "build_fixture_output_directory") ``` -------------------------------- ### Consolidate Server Certificate and Key Source: https://github.com/questdb/c-questdb-client/blob/main/tls_certs/README.md Concatenates the server certificate and private key into a single PEM file, often required by tools like haproxy. ```bash $ cat server.crt server.key > server.pem ``` -------------------------------- ### Create Executable and Link C++ Bindings Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/cxxbridge/cxxbridge_rust2cpp/CMakeLists.txt Defines an executable target and links it with the generated C++ bindings from the Rust crate. This allows the C++ executable to call Rust functions exposed through cxxbridge. ```cmake add_executable(cxxbridge-exe main.cpp) target_link_libraries(cxxbridge-exe PUBLIC cxxbridge-cpp) ``` -------------------------------- ### Basic QuestDB Ingestion with Rust Source: https://github.com/questdb/c-questdb-client/blob/main/questdb-rs/README.md Connects to a local QuestDB server and ingests a trade record with basic columns, symbol columns, and array columns. Requires QuestDB 9.0.0+ for array ingestion. ```rust use questdb:: Result, ingress:: Sender, Buffer, TimestampNanos; fn main() -> Result<()> { let mut sender = Sender::from_conf("http::addr=localhost:9000;")?; let mut buffer = sender.new_buffer(); buffer .table("trades")? .symbol("symbol", "ETH-USD")? .symbol("side", "sell")? .column_f64("price", 2615.54)? .column_f64("amount", 0.00044)? // Array ingestion (QuestDB 9.0.0+). Slices and ndarray supported through trait .column_arr("price_history", &[2615.54f64, 2615.10, 2614.80])? .column_arr("volatility", &ndarray::arr1(&[0.012f64, 0.011, 0.013]).view())? .at(TimestampNanos::now())?; sender.flush(&mut buffer)?; Ok(()) } ``` -------------------------------- ### Set Test Properties for Workspace Run Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/workspace/CMakeLists.txt Configures properties for the 'workspace_run_my_program' test, expecting a successful output pattern. ```cmake set_tests_properties("workspace_run_my_program" PROPERTIES PASS_REGULAR_EXPRESSION "^Ok\r?\n$" ) ``` -------------------------------- ### Importing a Static Library Crate Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/crate_type/crate_type/CMakeLists.txt Imports a Rust crate as a static library. Use this when you need a self-contained library that is linked directly into the executable. ```cmake corrosion_import_crate(MANIFEST_PATH proj1/Cargo.toml CRATE_TYPES staticlib FLAGS --crate-type=staticlib) ``` -------------------------------- ### Build and Test Rust Components Source: https://github.com/questdb/c-questdb-client/blob/main/CONTRIBUTING.md Build and test the core Rust crate with all compatible features enabled. This is the canonical lint target for Rust code. ```sh cd questdb-rs cargo build --features almost-all-features cargo test --features almost-all-features ``` -------------------------------- ### Construct and Send a Data Row Source: https://github.com/questdb/c-questdb-client/blob/main/doc/CPP.md Builds a single data row (message) with table name, symbols, columns, and a timestamp, then flushes it to QuestDB. Ensure symbols are added before columns. ```cpp questdb::ingress::line_sender_buffer buffer; buffer .table("trades") .symbol("symbol", "ETH-USD") .column("price", "2615.54"_decimal) .at(timestamp_nanos::now()); // To insert more records, call `buffer.table(..)...` again. sender.flush(buffer); ``` -------------------------------- ### Include Corrosion as a Subdirectory Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/doc/src/setup_corrosion.md After adding Corrosion as a git submodule or copying it into your source tree, include it in your CMakeLists.txt using add_subdirectory. ```cmake add_subdirectory(path/to/corrosion) ``` -------------------------------- ### Enable Corrosion Tests Option Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/CMakeLists.txt Enables or disables the execution of Corrosion tests. This option is advanced and defaults to ON. ```cmake option(CORROSION_TESTS "Enable Corrosion tests" ON) mark_as_advanced(CORROSION_TESTS) if(NOT CORROSION_TESTS) return() endif() ``` -------------------------------- ### Create Release Branch Source: https://github.com/questdb/c-questdb-client/blob/main/doc/RELEASING.md Create a new branch for the release, named according to the version number (e.g., vX.Y.Z). ```bash git switch -c vX.Y.Z ``` -------------------------------- ### Create Executable and Link Rust Library Source: https://github.com/questdb/c-questdb-client/blob/main/corrosion/test/output directory/output directory/CMakeLists.txt Defines a C++ executable target and links it against a Rust library. This establishes the dependency and allows the C++ code to use the Rust library. ```cmake add_executable(consumer consumer.cpp) add_dependencies(consumer cargo-build_rust_lib2) target_link_libraries(consumer rust_lib2) ``` -------------------------------- ### Enable Pre-commit Hook Source: https://github.com/questdb/c-questdb-client/blob/main/CONTRIBUTING.md Enable the pre-commit hook for the repository to automatically run code formatting and linting checks on staged commits. ```sh git config core.hooksPath .githooks ```