Skip to content

Commit 1395ea1

Browse files
committed
Update remote_encryption builder to take obj instead of option
1 parent 3e6b5cc commit 1395ea1

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

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

@@ -427,11 +427,14 @@ cfg_replication! {
427427

428428
if res.status().is_success() {
429429
tracing::trace!("Using sync protocol v2 for {}", url);
430-
let builder = Builder::new_synced_database(path, url, auth_token)
430+
let mut builder = Builder::new_synced_database(path, url, auth_token)
431431
.connector(connector)
432432
.remote_writes(true)
433-
.read_your_writes(read_your_writes)
434-
.remote_encryption(remote_encryption);
433+
.read_your_writes(read_your_writes);
434+
435+
if let Some(encryption) = remote_encryption {
436+
builder = builder.remote_encryption(encryption);
437+
}
435438

436439
let builder = if let Some(sync_interval) = sync_interval {
437440
builder.sync_interval(sync_interval)
@@ -616,8 +619,8 @@ cfg_sync! {
616619
}
617620

618621
/// Set the encryption context if the database is encrypted in remote server.
619-
pub fn remote_encryption(mut self, encryption_context: Option<EncryptionContext>) -> Builder<SyncedDatabase> {
620-
self.inner.remote_encryption = encryption_context;
622+
pub fn remote_encryption(mut self, encryption_context: EncryptionContext) -> Builder<SyncedDatabase> {
623+
self.inner.remote_encryption = Some(encryption_context);
621624
self
622625
}
623626

@@ -784,8 +787,8 @@ cfg_remote! {
784787
}
785788

786789
/// Set the encryption context if the database is encrypted in remote server.
787-
pub fn remote_encryption(mut self, encryption_context: Option<EncryptionContext>) -> Builder<Remote> {
788-
self.inner.remote_encryption = encryption_context;
790+
pub fn remote_encryption(mut self, encryption_context: EncryptionContext) -> Builder<Remote> {
791+
self.inner.remote_encryption = Some(encryption_context);
789792
self
790793
}
791794

0 commit comments

Comments
 (0)