Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions sdk/cosmos/.dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ backoff
pluggable
cloneable

# Here at Cosmos DB, we upserts, they're the best ;)
upsert
upserts
upserted
upserting

# Cosmos' docs all use "Autoscale" as a single word, rather than a compound "AutoScale" or "Auto Scale"
autoscale

# Words used within the Cosmos Native Client (azure_data_cosmos_native)
azurecosmos
cosmosclient
cstring
2 changes: 1 addition & 1 deletion sdk/cosmos/azure_data_cosmos/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub struct SystemProperties {
///
/// Returned by [`DatabaseClient::read()`](crate::clients::DatabaseClient::read()).
#[non_exhaustive]
#[derive(Clone, Default, Debug, Deserialize, PartialEq, Eq)]
#[derive(Clone, Default, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct DatabaseProperties {
/// The ID of the database.
pub id: String,
Expand Down
10 changes: 7 additions & 3 deletions sdk/cosmos/azure_data_cosmos_native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# cSpell:ignore cosmosctest CRATETYPES endforeach

project(cosmosctest C)
cmake_minimum_required(VERSION 4.1)
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The project() command should be called before cmake_minimum_required() according to CMake best practices. While this code moves project() after cmake_minimum_required() (which is correct), the version 4.1 appears incorrect as CMake versions follow a 3.x numbering scheme. This should likely be VERSION 3.1 or higher.

Suggested change
cmake_minimum_required(VERSION 4.1)
cmake_minimum_required(VERSION 3.15)

Copilot uses AI. Check for mistakes.

project(cosmosctest C)

# CMake automatically uses this option, but we should define it.
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)

Expand All @@ -18,11 +19,14 @@ FetchContent_MakeAvailable(Corrosion)

corrosion_import_crate(
MANIFEST_PATH ./Cargo.toml
CRATETYPES staticlib cdylib
PROFILE dev
)

set(TEST_FILES
./c_tests/version.c)
./c_tests/version.c
./c_tests/item_crud.c
./c_tests/context_memory_management.c
./c_tests/error_handling.c)

foreach(test_file ${TEST_FILES})
get_filename_component(test_name ${test_file} NAME_WE)
Expand Down
21 changes: 20 additions & 1 deletion sdk/cosmos/azure_data_cosmos_native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,26 @@ name = "azurecosmos"
crate-type = ["cdylib", "staticlib"]

[dependencies]
azure_data_cosmos = { path = "../azure_data_cosmos" }
futures.workspace = true
serde_json = { workspace = true, features = ["raw_value"] }
azure_core.workspace = true
azure_data_cosmos = { path = "../azure_data_cosmos", features = [ "key_auth", "preview_query_engine" ] }
tracing.workspace = true
tracing-subscriber = { workspace = true, optional = true, features = ["fmt", "env-filter"] }

[target.'cfg(target_family = "wasm")'.dependencies]
# The 'rt-multi-thread' feature is not supported in wasm targets
tokio = { workspace = true, optional = true, features = ["rt", "macros"] }

[target.'cfg(not(target_family = "wasm"))'.dependencies]
tokio = { workspace = true, optional = true, features = ["rt-multi-thread", "macros"] }

[features]
default = ["tokio", "reqwest", "reqwest_native_tls", "tracing"]
tokio = ["dep:tokio"]
reqwest = ["azure_core/reqwest"]
reqwest_native_tls = ["azure_core/reqwest_native_tls"]
tracing = ["dep:tracing-subscriber"]

[build-dependencies]
cbindgen = "0.29.0"
Expand Down
75 changes: 62 additions & 13 deletions sdk/cosmos/azure_data_cosmos_native/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

// cSpell:ignore SOURCEVERSION, SOURCEBRANCH, BUILDID, BUILDNUMBER, COSMOSCLIENT, cosmosclient, libcosmosclient, cbindgen

use std::collections::HashMap;

fn main() {
let build_id = format!(
"$Id: {}, Version: {}, Commit: {}, Branch: {}, Build ID: {}, Build Number: {}, Timestamp: {}$",
env!("CARGO_PKG_NAME"),
"azurecosmos",
env!("CARGO_PKG_VERSION"),
option_env!("BUILD_SOURCEVERSION").unwrap_or("unknown"),
option_env!("BUILD_SOURCEBRANCH").unwrap_or("unknown"),
Expand All @@ -19,26 +21,73 @@ fn main() {
);
println!("cargo:rustc-env=BUILD_IDENTIFIER={}", build_id);

let mut header: String = r"// Copyright (c) Microsoft Corporation. All rights reserved.
let header: String = r"// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// This file is auto-generated by cbindgen. Do not edit manually.
// cSpell: disable
"
.to_string();
header.push_str(&format!("// Build identifier: {}\n", build_id));

let config = cbindgen::Config {
language: cbindgen::Language::C,
header: Some(header),
after_includes: Some(
"\n// Specifies the version of cosmosclient this header file was generated from.\n// This should match the version of libcosmosclient you are referencing.\n#define COSMOSCLIENT_H_VERSION \"".to_string()
+ env!("CARGO_PKG_VERSION")
+ "\"",
),
cpp_compat: true,
parse: cbindgen::ParseConfig {
parse_deps: true,
include: Some(vec!["azure_data_cosmos".into()]),
..Default::default()
},
style: cbindgen::Style::Both,
enumeration: cbindgen::EnumConfig {
rename_variants: cbindgen::RenameRule::QualifiedScreamingSnakeCase,
..Default::default()
},
documentation_length: cbindgen::DocumentationLength::Full,
documentation_style: cbindgen::DocumentationStyle::Doxy,
export: cbindgen::ExportConfig {
prefix: Some("cosmos_".into()),
exclude: vec!["PartitionKeyValue".into()],

// From what I can tell, there's no way to set a rename rule for types :(
rename: HashMap::from([
("RuntimeContext".into(), "runtime_context".into()),
("CallContext".into(), "call_context".into()),
("CosmosError".into(), "error".into()),
("CosmosErrorCode".into(), "error_code".into()),
("CosmosClient".into(), "client".into()),
("DatabaseClient".into(), "database_client".into()),
("ContainerClient".into(), "container_client".into()),
("ClientOptions".into(), "client_options".into()),
("QueryOptions".into(), "query_options".into()),
("CreateDatabaseOptions".into(), "create_database_options".into()),
("ReadDatabaseOptions".into(), "read_database_options".into()),
("DeleteDatabaseOptions".into(), "delete_database_options".into()),
("CreateContainerOptions".into(), "create_container_options".into()),
("ReadContainerOptions".into(), "read_container_options".into()),
("DeleteContainerOptions".into(), "delete_container_options".into()),
("ItemOptions".into(), "item_options".into()),
("RuntimeOptions".into(), "runtime_options".into()),
("CallContextOptions".into(), "call_context_options".into()),
]),
..Default::default()
},
..Default::default()
};

let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
cbindgen::Builder::new()
let Ok(bindings) = cbindgen::Builder::new()
.with_crate(crate_dir)
.with_language(cbindgen::Language::C)
.with_after_include(format!(
"\n// Specifies the version of cosmosclient this header file was generated from.\n// This should match the version of libcosmosclient you are referencing.\n#define COSMOSCLIENT_H_VERSION \"{}\"",
env!("CARGO_PKG_VERSION")
))
.with_cpp_compat(true)
.with_header(header)
.with_config(config)
.generate()
.expect("unable to generate bindings")
.write_to_file("include/cosmosclient.h");
else {
println!("cargo:error=Failed to generate C bindings for azure_data_cosmos_native");
return;
};
bindings.write_to_file("include/azurecosmos.h");
}
Loading