From 9b8e11aab9dced21ee0486c6328a97ba9b088553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 13 Aug 2020 11:06:26 +0200 Subject: [PATCH] crypto: Fix the docs for our features. --- matrix_sdk/Cargo.toml | 4 ++-- matrix_sdk/src/lib.rs | 2 +- matrix_sdk_base/Cargo.toml | 4 ++-- matrix_sdk_base/src/client.rs | 4 ++-- matrix_sdk_base/src/lib.rs | 2 +- matrix_sdk_crypto/Cargo.toml | 7 ++++++- matrix_sdk_crypto/src/lib.rs | 3 ++- matrix_sdk_crypto/src/machine.rs | 7 ++++--- matrix_sdk_crypto/src/store/mod.rs | 6 +++--- 9 files changed, 23 insertions(+), 16 deletions(-) diff --git a/matrix_sdk/Cargo.toml b/matrix_sdk/Cargo.toml index cdbb4c27..dac12605 100644 --- a/matrix_sdk/Cargo.toml +++ b/matrix_sdk/Cargo.toml @@ -11,10 +11,10 @@ repository = "https://github.com/matrix-org/matrix-rust-sdk" version = "0.1.0" [features] -default = ["encryption", "sqlite-cryptostore", "messages"] +default = ["encryption", "sqlite_cryptostore", "messages"] messages = ["matrix-sdk-base/messages"] encryption = ["matrix-sdk-base/encryption", "dashmap"] -sqlite-cryptostore = ["matrix-sdk-base/sqlite-cryptostore"] +sqlite_cryptostore = ["matrix-sdk-base/sqlite_cryptostore"] [dependencies] async-trait = "0.1.36" diff --git a/matrix_sdk/src/lib.rs b/matrix_sdk/src/lib.rs index 4d1fe0ea..cd9d866e 100644 --- a/matrix_sdk/src/lib.rs +++ b/matrix_sdk/src/lib.rs @@ -20,7 +20,7 @@ //! The following crate feature flags are available: //! //! * `encryption`: Enables end-to-end encryption support in the library. -//! * `sqlite-cryptostore`: Enables a SQLite based store for the encryption +//! * `sqlite_cryptostore`: Enables a SQLite based store for the encryption //! keys. If this is disabled and `encryption` support is enabled the keys will //! by default be stored only in memory and thus lost after the client is //! destroyed. diff --git a/matrix_sdk_base/Cargo.toml b/matrix_sdk_base/Cargo.toml index b4985c42..f7c5a79a 100644 --- a/matrix_sdk_base/Cargo.toml +++ b/matrix_sdk_base/Cargo.toml @@ -11,10 +11,10 @@ repository = "https://github.com/matrix-org/matrix-rust-sdk" version = "0.1.0" [features] -default = ["encryption", "sqlite-cryptostore", "messages"] +default = ["encryption", "sqlite_cryptostore", "messages"] messages = [] encryption = ["matrix-sdk-crypto"] -sqlite-cryptostore = ["matrix-sdk-crypto/sqlite-cryptostore"] +sqlite_cryptostore = ["matrix-sdk-crypto/sqlite_cryptostore"] [dependencies] async-trait = "0.1.36" diff --git a/matrix_sdk_base/src/client.rs b/matrix_sdk_base/src/client.rs index c29e8219..6334041b 100644 --- a/matrix_sdk_base/src/client.rs +++ b/matrix_sdk_base/src/client.rs @@ -496,7 +496,7 @@ impl BaseClient { .map_err(OlmError::from)?, ); } else if let Some(path) = self.store_path.as_ref() { - #[cfg(feature = "sqlite-cryptostore")] + #[cfg(feature = "sqlite_cryptostore")] { *olm = Some( OlmMachine::new_with_default_store( @@ -509,7 +509,7 @@ impl BaseClient { .map_err(OlmError::from)?, ); } - #[cfg(not(feature = "sqlite-cryptostore"))] + #[cfg(not(feature = "sqlite_cryptostore"))] { *olm = Some(OlmMachine::new(&session.user_id, &session.device_id)); } diff --git a/matrix_sdk_base/src/lib.rs b/matrix_sdk_base/src/lib.rs index ad979708..666db669 100644 --- a/matrix_sdk_base/src/lib.rs +++ b/matrix_sdk_base/src/lib.rs @@ -20,7 +20,7 @@ //! The following crate feature flags are available: //! //! * `encryption`: Enables end-to-end encryption support in the library. -//! * `sqlite-cryptostore`: Enables a SQLite based store for the encryption +//! * `sqlite_cryptostore`: Enables a SQLite based store for the encryption //! keys. If this is disabled and `encryption` support is enabled the keys will //! by default be stored only in memory and thus lost after the client is //! destroyed. diff --git a/matrix_sdk_crypto/Cargo.toml b/matrix_sdk_crypto/Cargo.toml index d532a09d..5db2ab5d 100644 --- a/matrix_sdk_crypto/Cargo.toml +++ b/matrix_sdk_crypto/Cargo.toml @@ -10,9 +10,14 @@ readme = "README.md" repository = "https://github.com/matrix-org/matrix-rust-sdk" version = "0.1.0" +[package.metadata.docs.rs] +features = ["docs"] +rustdoc-args = ["--cfg", "feature=\"docs\""] + [features] default = [] -sqlite-cryptostore = ["sqlx"] +sqlite_cryptostore = ["sqlx"] +docs = ["sqlite_cryptostore"] [dependencies] async-trait = "0.1.36" diff --git a/matrix_sdk_crypto/src/lib.rs b/matrix_sdk_crypto/src/lib.rs index 69e0b518..36b842d4 100644 --- a/matrix_sdk_crypto/src/lib.rs +++ b/matrix_sdk_crypto/src/lib.rs @@ -25,6 +25,7 @@ unused_import_braces, unused_qualifications )] +#![cfg_attr(feature = "docs", feature(doc_cfg))] mod device; mod error; @@ -39,7 +40,7 @@ pub use error::{MegolmError, OlmError}; pub use machine::{OlmMachine, OneTimeKeys}; pub use memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices}; pub use olm::{Account, IdentityKeys, InboundGroupSession, OutboundGroupSession, Session}; -#[cfg(feature = "sqlite-cryptostore")] +#[cfg(feature = "sqlite_cryptostore")] pub use store::sqlite::SqliteStore; pub use store::{CryptoStore, CryptoStoreError}; pub use verification::Sas; diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index e65644c2..127be8fe 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(feature = "sqlite-cryptostore")] +#[cfg(feature = "sqlite_cryptostore")] use std::path::Path; use std::{ collections::{BTreeMap, HashSet}, @@ -47,7 +47,7 @@ use matrix_sdk_common::{ Raw, }; -#[cfg(feature = "sqlite-cryptostore")] +#[cfg(feature = "sqlite_cryptostore")] use super::store::sqlite::SqliteStore; use super::{ device::Device, @@ -182,8 +182,9 @@ impl OlmMachine { /// * `user_id` - The unique id of the user that owns this machine. /// /// * `device_id` - The unique id of the device that owns this machine. - #[cfg(feature = "sqlite-cryptostore")] + #[cfg(feature = "sqlite_cryptostore")] #[instrument(skip(path, passphrase))] + #[cfg_attr(feature = "docs", doc(cfg(r#sqlite_cryptostore)))] pub async fn new_with_default_store>( user_id: &UserId, device_id: &DeviceId, diff --git a/matrix_sdk_crypto/src/store/mod.rs b/matrix_sdk_crypto/src/store/mod.rs index 9b035450..f4dc7e94 100644 --- a/matrix_sdk_crypto/src/store/mod.rs +++ b/matrix_sdk_crypto/src/store/mod.rs @@ -35,11 +35,11 @@ use super::{ pub mod memorystore; #[cfg(not(target_arch = "wasm32"))] -#[cfg(feature = "sqlite-cryptostore")] +#[cfg(feature = "sqlite_cryptostore")] pub mod sqlite; #[cfg(not(target_arch = "wasm32"))] -#[cfg(feature = "sqlite-cryptostore")] +#[cfg(feature = "sqlite_cryptostore")] use sqlx::Error as SqlxError; #[derive(Error, Debug)] @@ -53,7 +53,7 @@ pub enum CryptoStoreError { /// SQL error occurred. // TODO flatten the SqlxError to make it easier for other store // implementations. - #[cfg(feature = "sqlite-cryptostore")] + #[cfg(feature = "sqlite_cryptostore")] #[error(transparent)] DatabaseError(#[from] SqlxError),