Skip to content
Merged
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "springql-client-c"
version = "0.3.0"
version = "0.3.1"

authors = ["Sho Nakatani <lay.sakura@gmail.com>"]
license = "MIT OR Apache-2.0"
Expand All @@ -15,6 +15,6 @@ name = "springql_client"
cbindgen = "0.21"

[dependencies]
springql-core = "0.3"
springql-core = "0.3.1"

log = "0.4"
4 changes: 3 additions & 1 deletion c_example/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ int main()
{
SpringErrno ret;

SpringConfig *config = spring_config_default();
SpringConfig *config = spring_config_toml(
"[memory]\n"
"upper_limit_bytes = 1_000_000\n");
assert_not_null(config);

SpringPipeline *pipeline = spring_open(config);
Expand Down
15 changes: 15 additions & 0 deletions springql.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,24 @@ typedef void *SpringRow;

/**
* See: springql_core::api::spring_config_default
*
* Returned value is not modifiable (it is just a void pointer).
* If you would like to change the default configuration, use `spring_config_toml()` instead.
*/
SpringConfig *spring_config_default(void);

/**
* See: springql_core::api::spring_config_default
*
* Returned value is not modifiable (it is just a void pointer).
* If you would like to change the default configuration, use `spring_config_toml()` instead.
*
* # Safety
*
* This function is unsafe because it uses raw pointer.
*/
SpringConfig *spring_config_toml(const char *overwrite_config_toml);

/**
* # Returns
*
Expand Down
22 changes: 22 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ pub struct SpringPipeline(*mut c_void);
pub struct SpringRow(*mut c_void);

/// See: springql_core::api::spring_config_default
///
/// Returned value is not modifiable (it is just a void pointer).
/// If you would like to change the default configuration, use `spring_config_toml()` instead.
#[no_mangle]
pub extern "C" fn spring_config_default() -> *mut SpringConfig {
let config = springql_core::spring_config_default();
Expand All @@ -44,6 +47,25 @@ pub extern "C" fn spring_config_default() -> *mut SpringConfig {
})))
}

/// See: springql_core::api::spring_config_default
///
/// Returned value is not modifiable (it is just a void pointer).
/// If you would like to change the default configuration, use `spring_config_toml()` instead.
///
/// # Safety
///
/// This function is unsafe because it uses raw pointer.
#[no_mangle]
pub unsafe extern "C" fn spring_config_toml(
overwrite_config_toml: *const c_char,
) -> *mut SpringConfig {
let s = { CStr::from_ptr(overwrite_config_toml) };
let s = s.to_str().expect("failed to parse TOML string into UTF-8");

let config = springql_core::spring_config_toml(s).expect("failed to parse TOML config");
Box::into_raw(Box::new(SpringConfig(mem::transmute(Box::new(config)))))
}

/// # Returns
///
/// - `0`: if there are no recent errors.
Expand Down