matrix-sdk: Fix the docs for our feature flags.

master
Damir Jelić 2020-08-13 12:18:24 +02:00
parent d4de877e09
commit d4e31f07a1
3 changed files with 22 additions and 8 deletions

View File

@ -10,12 +10,19 @@ readme = "README.md"
repository = "https://github.com/matrix-org/matrix-rust-sdk" repository = "https://github.com/matrix-org/matrix-rust-sdk"
version = "0.1.0" version = "0.1.0"
[package.metadata.docs.rs]
features = ["docs"]
rustdoc-args = ["--cfg", "feature=\"docs\""]
[features] [features]
default = ["encryption", "sqlite_cryptostore", "messages"] default = ["encryption", "sqlite_cryptostore", "messages"]
messages = ["matrix-sdk-base/messages"] messages = ["matrix-sdk-base/messages"]
encryption = ["matrix-sdk-base/encryption", "dashmap"] encryption = ["matrix-sdk-base/encryption", "dashmap"]
sqlite_cryptostore = ["matrix-sdk-base/sqlite_cryptostore"] sqlite_cryptostore = ["matrix-sdk-base/sqlite_cryptostore"]
docs = ["encryption", "sqlite_cryptostore", "messages"]
[dependencies] [dependencies]
async-trait = "0.1.36" async-trait = "0.1.36"
dashmap = { version = "3.11.10", optional = true } dashmap = { version = "3.11.10", optional = true }

View File

@ -953,6 +953,7 @@ impl Client {
/// ///
/// Does nothing if no group session needs to be shared. /// Does nothing if no group session needs to be shared.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(feature = "docs", doc(cfg(encryption)))]
async fn preshare_group_session(&self, room_id: &RoomId) -> Result<()> { async fn preshare_group_session(&self, room_id: &RoomId) -> Result<()> {
// TODO expose this publicly so people can pre-share a group session if // TODO expose this publicly so people can pre-share a group session if
// e.g. a user starts to type a message for a room. // e.g. a user starts to type a message for a room.
@ -1318,7 +1319,7 @@ impl Client {
/// Panics if the client isn't logged in, or if no encryption keys need to /// Panics if the client isn't logged in, or if no encryption keys need to
/// be uploaded. /// be uploaded.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
#[instrument] #[instrument]
async fn claim_one_time_keys( async fn claim_one_time_keys(
&self, &self,
@ -1347,7 +1348,7 @@ impl Client {
/// ///
/// Panics if the client isn't logged in. /// Panics if the client isn't logged in.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
#[instrument] #[instrument]
async fn share_group_session(&self, room_id: &RoomId) -> Result<()> { async fn share_group_session(&self, room_id: &RoomId) -> Result<()> {
let mut requests = self let mut requests = self
@ -1373,7 +1374,7 @@ impl Client {
/// Panics if the client isn't logged in, or if no encryption keys need to /// Panics if the client isn't logged in, or if no encryption keys need to
/// be uploaded. /// be uploaded.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
#[instrument] #[instrument]
async fn keys_upload(&self) -> Result<upload_keys::Response> { async fn keys_upload(&self) -> Result<upload_keys::Response> {
let request = self let request = self
@ -1407,7 +1408,7 @@ impl Client {
/// ///
/// Panics if no key query needs to be done. /// Panics if no key query needs to be done.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
#[instrument] #[instrument]
async fn keys_query(&self) -> Result<get_keys::Response> { async fn keys_query(&self) -> Result<get_keys::Response> {
let mut users_for_query = self let mut users_for_query = self
@ -1443,7 +1444,7 @@ impl Client {
/// Get a `Sas` verification object with the given flow id. /// Get a `Sas` verification object with the given flow id.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn get_verification(&self, flow_id: &str) -> Option<Sas> { pub async fn get_verification(&self, flow_id: &str) -> Option<Sas> {
self.base_client self.base_client
.get_verification(flow_id) .get_verification(flow_id)
@ -1465,7 +1466,7 @@ impl Client {
/// ///
/// Returns a `Sas` object that represents the interactive verification flow. /// Returns a `Sas` object that represents the interactive verification flow.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn start_verification(&self, device: Device) -> Result<Sas> { pub async fn start_verification(&self, device: Device) -> Result<Sas> {
let (sas, request) = self let (sas, request) = self
.base_client .base_client
@ -1513,7 +1514,7 @@ impl Client {
/// # }); /// # });
/// ``` /// ```
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn get_device(&self, user_id: &UserId, device_id: &DeviceId) -> Option<Device> { pub async fn get_device(&self, user_id: &UserId, device_id: &DeviceId) -> Option<Device> {
self.base_client.get_device(user_id, device_id).await self.base_client.get_device(user_id, device_id).await
} }
@ -1546,7 +1547,7 @@ impl Client {
/// # }); /// # });
/// ``` /// ```
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn get_user_devices( pub async fn get_user_devices(
&self, &self,
user_id: &UserId, user_id: &UserId,

View File

@ -35,6 +35,7 @@
unused_import_braces, unused_import_braces,
unused_qualifications unused_qualifications
)] )]
#![cfg_attr(feature = "docs", feature(doc_cfg))]
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
pub use matrix_sdk_base::JsonStore; pub use matrix_sdk_base::JsonStore;
@ -42,9 +43,13 @@ pub use matrix_sdk_base::{
CustomEvent, Error as BaseError, EventEmitter, Room, RoomState, Session, StateStore, SyncRoom, CustomEvent, Error as BaseError, EventEmitter, Room, RoomState, Session, StateStore, SyncRoom,
}; };
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub use matrix_sdk_base::{Device, TrustState}; pub use matrix_sdk_base::{Device, TrustState};
#[cfg(feature = "messages")] #[cfg(feature = "messages")]
#[cfg_attr(feature = "docs", doc(cfg(messages)))]
pub use matrix_sdk_base::{MessageQueue, PossiblyRedactedExt}; pub use matrix_sdk_base::{MessageQueue, PossiblyRedactedExt};
pub use matrix_sdk_common::*; pub use matrix_sdk_common::*;
pub use reqwest::header::InvalidHeaderValue; pub use reqwest::header::InvalidHeaderValue;
@ -63,6 +68,7 @@ pub use request_builder::{
MessagesRequestBuilder, RegistrationBuilder, RoomBuilder, RoomListFilterBuilder, MessagesRequestBuilder, RegistrationBuilder, RoomBuilder, RoomListFilterBuilder,
}; };
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub use sas::Sas; pub use sas::Sas;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]