crypto: Fix the docs for our features.

master
Damir Jelić 2020-08-13 11:06:26 +02:00
parent a0abffd026
commit 9b8e11aab9
9 changed files with 23 additions and 16 deletions

View File

@ -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"

View File

@ -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.

View File

@ -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"

View File

@ -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));
}

View File

@ -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.

View File

@ -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"

View File

@ -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;

View File

@ -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<P: AsRef<Path>>(
user_id: &UserId,
device_id: &DeviceId,

View File

@ -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),