From 8b3190d2547111f8eda33d38cf65aff270779dd8 Mon Sep 17 00:00:00 2001 From: nikurt <86772482+nikurt@users.noreply.github.com> Date: Tue, 23 Nov 2021 15:08:57 +0100 Subject: [PATCH] Add method for opening DB with ro access and cf descriptors (#569) --- src/db.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/db.rs b/src/db.rs index 8b2c7bb..6a31b42 100644 --- a/src/db.rs +++ b/src/db.rs @@ -333,6 +333,32 @@ impl DBWithThreadMode { ) } + /// Opens a database for read only with the given database options and column family names. + pub fn open_cf_with_opts_for_read_only( + db_opts: &Options, + path: P, + cfs: I, + error_if_log_file_exist: bool, + ) -> Result + where + P: AsRef, + I: IntoIterator, + N: AsRef, + { + let cfs = cfs + .into_iter() + .map(|(name, cf_opts)| ColumnFamilyDescriptor::new(name.as_ref(), cf_opts)); + + Self::open_cf_descriptors_internal( + db_opts, + path, + cfs, + &AccessType::ReadOnly { + error_if_log_file_exist, + }, + ) + } + /// Opens the database as a secondary with the given database options and column family names. pub fn open_cf_as_secondary( opts: &Options,