Skip to content

Commit 4fb1968

Browse files
authored
Allow removing deprecated from billeo-engine (#12)
The function `default_collection_or_error` is useful for database calls in transactions. Remove the `deprecated` flag inside structs that are still needed, else the deprecated warning is triggered even if the value is `None`.
1 parent 9191da6 commit 4fb1968

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

src/database.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,19 @@ impl Database {
482482
})
483483
}
484484

485+
pub fn default_collection_or_error(&self) -> Result<Collection> {
486+
let mut error = CBLError::default();
487+
let collection = unsafe { CBLDatabase_DefaultCollection(self.get_ref(), &mut error) };
488+
489+
check_error(&error)?;
490+
491+
if collection.is_null() {
492+
Err(Error::cbl_error(CouchbaseLiteError::NotFound))
493+
} else {
494+
Ok(Collection::retain(collection))
495+
}
496+
}
497+
485498
//////// NOTIFICATIONS:
486499

487500
/** Registers a database change listener function. It will be called after one or more

src/replicator.rs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -641,20 +641,11 @@ pub extern "C" fn c_collection_property_decryptor(
641641

642642
#[derive(Default)]
643643
pub struct ReplicationConfigurationContext {
644-
#[deprecated(note = "please use `collection.push_filter` on default collection instead")]
645-
pub push_filter: Option<ReplicationFilter>,
646-
#[deprecated(note = "please use `collection.pull_filter` on default collection instead")]
647-
pub pull_filter: Option<ReplicationFilter>,
648-
#[deprecated(note = "please use `collection.conflict_resolver` on default collection instead")]
649-
pub conflict_resolver: Option<ConflictResolver>,
650-
#[deprecated(
651-
note = "please use `collection_property_encryptor` on default collection instead"
652-
)]
653-
pub default_collection_property_encryptor: Option<DefaultCollectionPropertyEncryptor>,
654-
#[deprecated(
655-
note = "please use `collection_property_decryptor` on default collection instead"
656-
)]
657-
pub default_collection_property_decryptor: Option<DefaultCollectionPropertyDecryptor>,
644+
pub push_filter: Option<ReplicationFilter>, // TODO: deprecated
645+
pub pull_filter: Option<ReplicationFilter>, // TODO: deprecated
646+
pub conflict_resolver: Option<ConflictResolver>, // TODO: deprecated
647+
pub default_collection_property_encryptor: Option<DefaultCollectionPropertyEncryptor>, // TODO: deprecated
648+
pub default_collection_property_decryptor: Option<DefaultCollectionPropertyDecryptor>, // TODO: deprecated
658649
pub collection_property_encryptor: Option<CollectionPropertyEncryptor>,
659650
pub collection_property_decryptor: Option<CollectionPropertyDecryptor>,
660651
}
@@ -692,11 +683,11 @@ impl ReplicationCollection {
692683

693684
/** The configuration of a replicator. */
694685
pub struct ReplicatorConfiguration {
695-
#[deprecated(note = "use collections instead")]
686+
// TODO: deprecated
696687
pub database: Option<Database>, // The database to replicate. When setting the database, ONLY the default collection will be used for replication.
697-
pub endpoint: Endpoint, // The address of the other database to replicate with
688+
pub endpoint: Endpoint, // The address of the other database to replicate with
698689
pub replicator_type: ReplicatorType, // Push, pull or both
699-
pub continuous: bool, // Continuous replication?
690+
pub continuous: bool, // Continuous replication?
700691
//-- Auto Purge:
701692
/**
702693
If auto purge is active, then the library will automatically purge any documents that the replicating
@@ -721,9 +712,9 @@ pub struct ReplicatorConfiguration {
721712
pub pinned_server_certificate: Option<Vec<u8>>, // An X.509 cert to "pin" TLS connections to (PEM or DER)
722713
pub trusted_root_certificates: Option<Vec<u8>>, // Set of anchor certs (PEM format)
723714
//-- Filtering:
724-
#[deprecated(note = "please use `collection.channels` on default collection instead")]
715+
// TODO: deprecated
725716
pub channels: MutableArray, // Optional set of channels to pull from
726-
#[deprecated(note = "please use `collection.document_ids` on default collection instead")]
717+
// TODO: deprecated
727718
pub document_ids: MutableArray, // Optional set of document IDs to replicate
728719
pub collections: Option<Vec<ReplicationCollection>>, // The collections to replicate with the target's endpoint (Required if the database is not set).
729720
//-- Advanced HTTP settings:

0 commit comments

Comments
 (0)