@@ -46,7 +46,7 @@ use crate::{chatlist_events, stats};
4646///
4747/// # Examples
4848///
49- /// Creating a new unencrypted database:
49+ /// Creating a new database:
5050///
5151/// ```
5252/// # let rt = tokio::runtime::Runtime::new().unwrap();
@@ -61,24 +61,6 @@ use crate::{chatlist_events, stats};
6161/// drop(context);
6262/// # });
6363/// ```
64- ///
65- /// To use an encrypted database provide a password. If the database does not yet exist it
66- /// will be created:
67- ///
68- /// ```
69- /// # let rt = tokio::runtime::Runtime::new().unwrap();
70- /// # rt.block_on(async move {
71- /// use deltachat::context::ContextBuilder;
72- ///
73- /// let dir = tempfile::tempdir().unwrap();
74- /// let context = ContextBuilder::new(dir.path().join("db"))
75- /// .with_password("secret".into())
76- /// .open()
77- /// .await
78- /// .unwrap();
79- /// drop(context);
80- /// # });
81- /// ```
8264#[ derive( Clone , Debug ) ]
8365pub struct ContextBuilder {
8466 dbfile : PathBuf ,
@@ -150,9 +132,13 @@ impl ContextBuilder {
150132 }
151133
152134 /// Sets the password to unlock the database.
135+ /// Deprecated 2025-11:
136+ /// - Db encryption does nothing with blobs, so fs/disk encryption is recommended.
137+ /// - Isolation from other apps is needed anyway.
153138 ///
154139 /// If an encrypted database is used it must be opened with a password. Setting a
155140 /// password on a new database will enable encryption.
141+ #[ deprecated( since = "TBD" ) ]
156142 pub fn with_password ( mut self , password : String ) -> Self {
157143 self . password = Some ( password) ;
158144 self
@@ -180,7 +166,7 @@ impl ContextBuilder {
180166
181167 /// Builds the [`Context`] and opens it.
182168 ///
183- /// Returns error if context cannot be opened with the given passphrase .
169+ /// Returns error if context cannot be opened.
184170 pub async fn open ( self ) -> Result < Context > {
185171 let password = self . password . clone ( ) . unwrap_or_default ( ) ;
186172 let context = self . build ( ) . await ?;
@@ -400,9 +386,12 @@ impl Context {
400386 }
401387
402388 /// Opens the database with the given passphrase.
389+ /// NB: Db encryption is deprecated, so `passphrase` should be empty normally. See
390+ /// [`ContextBuilder::with_password()`] for reasoning.
403391 ///
404392 /// Returns true if passphrase is correct, false is passphrase is not correct. Fails on other
405393 /// errors.
394+ #[ deprecated( since = "TBD" ) ]
406395 pub async fn open ( & self , passphrase : String ) -> Result < bool > {
407396 if self . sql . check_passphrase ( passphrase. clone ( ) ) . await ? {
408397 self . sql . open ( self , passphrase) . await ?;
@@ -413,6 +402,7 @@ impl Context {
413402 }
414403
415404 /// Changes encrypted database passphrase.
405+ /// Deprecated 2025-11, see [`ContextBuilder::with_password()`] for reasoning.
416406 pub async fn change_passphrase ( & self , passphrase : String ) -> Result < ( ) > {
417407 self . sql . change_passphrase ( passphrase) . await ?;
418408 Ok ( ( ) )
0 commit comments