Skip to content

Commit 6a815d6

Browse files
committed
Update remote_encryption builder to take obj instead of option
1 parent 5057eae commit 6a815d6

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

libsql/src/database/builder.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ cfg_replication! {
306306

307307
/// Set the encryption context if the database is encrypted in remote server.
308308
#[cfg(feature = "sync")]
309-
pub fn remote_encryption(mut self, encryption_context: Option<EncryptionContext>) -> Builder<RemoteReplica> {
310-
self.inner.remote_encryption = encryption_context;
309+
pub fn remote_encryption(mut self, encryption_context: EncryptionContext) -> Builder<RemoteReplica> {
310+
self.inner.remote_encryption = Some(encryption_context);
311311
self
312312
}
313313

@@ -432,11 +432,14 @@ cfg_replication! {
432432

433433
if res.status().is_success() {
434434
tracing::trace!("Using sync protocol v2 for {}", url);
435-
let builder = Builder::new_synced_database(path, url, auth_token)
435+
let mut builder = Builder::new_synced_database(path, url, auth_token)
436436
.connector(connector)
437437
.remote_writes(true)
438-
.read_your_writes(read_your_writes)
439-
.remote_encryption(remote_encryption);
438+
.read_your_writes(read_your_writes);
439+
440+
if let Some(encryption) = remote_encryption {
441+
builder = builder.remote_encryption(encryption);
442+
}
440443

441444
let builder = if let Some(sync_interval) = sync_interval {
442445
builder.sync_interval(sync_interval)
@@ -621,8 +624,8 @@ cfg_sync! {
621624
}
622625

623626
/// Set the encryption context if the database is encrypted in remote server.
624-
pub fn remote_encryption(mut self, encryption_context: Option<EncryptionContext>) -> Builder<SyncedDatabase> {
625-
self.inner.remote_encryption = encryption_context;
627+
pub fn remote_encryption(mut self, encryption_context: EncryptionContext) -> Builder<SyncedDatabase> {
628+
self.inner.remote_encryption = Some(encryption_context);
626629
self
627630
}
628631

@@ -789,8 +792,8 @@ cfg_remote! {
789792
}
790793

791794
/// Set the encryption context if the database is encrypted in remote server.
792-
pub fn remote_encryption(mut self, encryption_context: Option<EncryptionContext>) -> Builder<Remote> {
793-
self.inner.remote_encryption = encryption_context;
795+
pub fn remote_encryption(mut self, encryption_context: EncryptionContext) -> Builder<Remote> {
796+
self.inner.remote_encryption = Some(encryption_context);
794797
self
795798
}
796799

0 commit comments

Comments
 (0)