Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bindings/c: Add offline to config struct #1943

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions bindings/c/include/libsql.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ typedef struct {
const char *encryption_key;
int sync_interval;
char with_webpki;
char offline;
} libsql_config;

typedef const libsql_connection *libsql_connection_t;
Expand Down
6 changes: 5 additions & 1 deletion bindings/c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub unsafe extern "C" fn libsql_open_sync(
encryption_key,
sync_interval: 0,
with_webpki: 0,
offline: 0,
};
libsql_open_sync_with_config(config, out_db, out_err_msg)
}
Expand All @@ -119,6 +120,7 @@ pub unsafe extern "C" fn libsql_open_sync_with_webpki(
encryption_key,
sync_interval: 0,
with_webpki: 1,
offline: 0,
};
libsql_open_sync_with_config(config, out_db, out_err_msg)
}
Expand Down Expand Up @@ -256,7 +258,9 @@ pub unsafe extern "C" fn libsql_open_sync_with_config(
return 100;
}
};
if let Some(primary_url) = primary_url_with_offline_removed {
let offline = config.offline != 0 || primary_url_with_offline_removed.is_some();
if offline {
let primary_url = primary_url_with_offline_removed.unwrap_or(primary_url.to_owned());
let mut builder =
Builder::new_synced_database(db_path, primary_url.to_owned(), auth_token.to_owned());
if config.with_webpki != 0 {
Expand Down
1 change: 1 addition & 0 deletions bindings/c/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct libsql_config {
pub encryption_key: *const std::ffi::c_char,
pub sync_interval: std::ffi::c_int,
pub with_webpki: std::ffi::c_char,
pub offline: std::ffi::c_char,
}

#[derive(Clone, Debug)]
Expand Down
Loading