base: Fix the docs for our feature flags.

master
Damir Jelić 2020-08-13 12:17:30 +02:00
parent 9b8e11aab9
commit d4de877e09
6 changed files with 33 additions and 26 deletions

View File

@ -10,12 +10,18 @@ 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 = [] messages = []
encryption = ["matrix-sdk-crypto"] encryption = ["matrix-sdk-crypto"]
sqlite_cryptostore = ["matrix-sdk-crypto/sqlite_cryptostore"] sqlite_cryptostore = ["matrix-sdk-crypto/sqlite_cryptostore"]
docs = ["encryption", "sqlite_cryptostore", "messages"]
[dependencies] [dependencies]
async-trait = "0.1.36" async-trait = "0.1.36"
serde = "1.0.115" serde = "1.0.115"

View File

@ -1231,7 +1231,7 @@ impl BaseClient {
/// Should account or one-time keys be uploaded to the server. /// Should account or one-time keys be uploaded to the server.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn should_upload_keys(&self) -> bool { pub async fn should_upload_keys(&self) -> bool {
let olm = self.olm.lock().await; let olm = self.olm.lock().await;
@ -1250,7 +1250,7 @@ impl BaseClient {
/// This should be called every time a new room message wants to be sent out /// This should be called every time a new room message wants to be sent out
/// since group sessions can expire at any time. /// since group sessions can expire at any time.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn should_share_group_session(&self, room_id: &RoomId) -> bool { pub async fn should_share_group_session(&self, room_id: &RoomId) -> bool {
let olm = self.olm.lock().await; let olm = self.olm.lock().await;
@ -1262,7 +1262,7 @@ impl BaseClient {
/// Should users be queried for their device keys. /// Should users be queried for their device keys.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn should_query_keys(&self) -> bool { pub async fn should_query_keys(&self) -> bool {
let olm = self.olm.lock().await; let olm = self.olm.lock().await;
@ -1276,7 +1276,7 @@ impl BaseClient {
/// ///
/// Returns an empty error if no keys need to be uploaded. /// Returns an empty error if no keys need to be uploaded.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn get_missing_sessions( pub async fn get_missing_sessions(
&self, &self,
users: impl Iterator<Item = &UserId>, users: impl Iterator<Item = &UserId>,
@ -1291,7 +1291,7 @@ impl BaseClient {
/// Get a to-device request that will share a group session for a room. /// Get a to-device request that will share a group session for a room.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn share_group_session(&self, room_id: &RoomId) -> Result<Vec<OwnedToDeviceRequest>> { pub async fn share_group_session(&self, room_id: &RoomId) -> Result<Vec<OwnedToDeviceRequest>> {
let room = self.get_joined_room(room_id).await.expect("No room found"); let room = self.get_joined_room(room_id).await.expect("No room found");
let olm = self.olm.lock().await; let olm = self.olm.lock().await;
@ -1313,7 +1313,7 @@ impl BaseClient {
/// Encrypt a message event content. /// Encrypt a message event content.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn encrypt( pub async fn encrypt(
&self, &self,
room_id: &RoomId, room_id: &RoomId,
@ -1331,7 +1331,7 @@ impl BaseClient {
/// ///
/// Returns an empty error if no keys need to be uploaded. /// Returns an empty error if no keys need to be uploaded.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn keys_for_upload(&self) -> StdResult<KeysUploadRequest, ()> { pub async fn keys_for_upload(&self) -> StdResult<KeysUploadRequest, ()> {
let olm = self.olm.lock().await; let olm = self.olm.lock().await;
@ -1345,7 +1345,7 @@ impl BaseClient {
/// ///
/// Returns an empty error if no keys need to be queried. /// Returns an empty error if no keys need to be queried.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn users_for_key_query(&self) -> StdResult<HashSet<UserId>, ()> { pub async fn users_for_key_query(&self) -> StdResult<HashSet<UserId>, ()> {
let olm = self.olm.lock().await; let olm = self.olm.lock().await;
@ -1365,7 +1365,7 @@ impl BaseClient {
/// # Panics /// # Panics
/// Panics if the client hasn't been logged in. /// Panics if the client hasn't been logged in.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn receive_keys_upload_response(&self, response: &KeysUploadResponse) -> Result<()> { pub async fn receive_keys_upload_response(&self, response: &KeysUploadResponse) -> Result<()> {
let olm = self.olm.lock().await; let olm = self.olm.lock().await;
@ -1384,7 +1384,7 @@ impl BaseClient {
/// # Panics /// # Panics
/// Panics if the client hasn't been logged in. /// Panics if the client hasn't been logged in.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn receive_keys_claim_response(&self, response: &KeysClaimResponse) -> Result<()> { pub async fn receive_keys_claim_response(&self, response: &KeysClaimResponse) -> Result<()> {
let olm = self.olm.lock().await; let olm = self.olm.lock().await;
@ -1403,7 +1403,7 @@ impl BaseClient {
/// # Panics /// # Panics
/// Panics if the client hasn't been logged in. /// Panics if the client hasn't been logged in.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn receive_keys_query_response(&self, response: &KeysQueryResponse) -> Result<()> { pub async fn receive_keys_query_response(&self, response: &KeysQueryResponse) -> Result<()> {
let olm = self.olm.lock().await; let olm = self.olm.lock().await;
@ -1419,7 +1419,7 @@ impl BaseClient {
/// Returns true if a session was invalidated, false if there was no session /// Returns true if a session was invalidated, false if there was no session
/// to invalidate. /// to invalidate.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn invalidate_group_session(&self, room_id: &RoomId) -> bool { pub async fn invalidate_group_session(&self, room_id: &RoomId) -> bool {
let olm = self.olm.lock().await; let olm = self.olm.lock().await;
@ -1831,7 +1831,7 @@ impl BaseClient {
/// Get the to-device requests that need to be sent out. /// Get the to-device requests that need to be sent out.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn outgoing_to_device_requests(&self) -> Vec<OwnedToDeviceRequest> { pub async fn outgoing_to_device_requests(&self) -> Vec<OwnedToDeviceRequest> {
self.olm self.olm
.lock() .lock()
@ -1843,7 +1843,7 @@ impl BaseClient {
/// Mark an outgoing to-device requests as sent. /// Mark an outgoing to-device requests as sent.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub async fn mark_to_device_request_as_sent(&self, request_id: &str) { pub async fn mark_to_device_request_as_sent(&self, request_id: &str) {
if let Some(olm) = self.olm.lock().await.as_ref() { if let Some(olm) = self.olm.lock().await.as_ref() {
olm.mark_to_device_request_as_sent(request_id) olm.mark_to_device_request_as_sent(request_id)
@ -1860,7 +1860,7 @@ impl BaseClient {
/// to-device verification flows this will be the transaction id of the /// to-device verification flows this will be the transaction id of the
/// *m.key.verification.start* event. /// *m.key.verification.start* event.
#[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.olm self.olm
.lock() .lock()
@ -1878,7 +1878,7 @@ impl BaseClient {
/// ///
/// Returns a `Sas` object and a to-device request that needs to be sent out. /// Returns a `Sas` object and a to-device request that needs to be sent out.
#[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) -> Option<(Sas, OwnedToDeviceRequest)> { pub async fn start_verification(&self, device: Device) -> Option<(Sas, OwnedToDeviceRequest)> {
self.olm self.olm
.lock() .lock()
@ -1916,7 +1916,7 @@ impl BaseClient {
/// # }); /// # });
/// ``` /// ```
#[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> {
let olm = self.olm.lock().await; let olm = self.olm.lock().await;
olm.as_ref()?.get_device(user_id, device_id).await olm.as_ref()?.get_device(user_id, device_id).await
@ -1949,7 +1949,7 @@ impl BaseClient {
/// # }); /// # });
/// ``` /// ```
#[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

@ -47,13 +47,13 @@ pub enum Error {
/// An error occurred during a E2EE operation. /// An error occurred during a E2EE operation.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
#[error(transparent)] #[error(transparent)]
OlmError(#[from] OlmError), OlmError(#[from] OlmError),
/// An error occurred during a E2EE group operation. /// An error occurred during a E2EE group operation.
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] #[cfg_attr(feature = "docs", doc(cfg(encryption)))]
#[error(transparent)] #[error(transparent)]
MegolmError(#[from] MegolmError), MegolmError(#[from] MegolmError),
} }

View File

@ -34,6 +34,7 @@
unused_import_braces, unused_import_braces,
unused_qualifications unused_qualifications
)] )]
#![cfg_attr(feature = "docs", feature(doc_cfg))]
pub use crate::{ pub use crate::{
error::{Error, Result}, error::{Error, Result},
@ -54,10 +55,11 @@ pub use models::Room;
pub use state::{AllRooms, ClientState}; pub use state::{AllRooms, ClientState};
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
#[cfg_attr(feature = "docs", doc(cfg(encryption)))]
pub use matrix_sdk_crypto::{CryptoStoreError, Device, Sas, TrustState, UserDevices}; pub use matrix_sdk_crypto::{CryptoStoreError, Device, Sas, TrustState, UserDevices};
#[cfg(feature = "messages")] #[cfg(feature = "messages")]
#[cfg_attr(docsrs, doc(cfg(feature = "messages")))] #[cfg_attr(feature = "docs", doc(cfg(messages)))]
pub use models::{MessageQueue, PossiblyRedactedExt}; pub use models::{MessageQueue, PossiblyRedactedExt};
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]

View File

@ -1,11 +1,10 @@
#[cfg(feature = "messages")] #[cfg(feature = "messages")]
#[cfg_attr(docsrs, doc(cfg(feature = "messages")))]
mod message; mod message;
mod room; mod room;
mod room_member; mod room_member;
#[cfg(feature = "messages")] #[cfg(feature = "messages")]
#[cfg_attr(docsrs, doc(cfg(feature = "messages")))] #[cfg_attr(feature = "docs", doc(cfg(messages)))]
pub use message::{MessageQueue, PossiblyRedactedExt}; pub use message::{MessageQueue, PossiblyRedactedExt};
pub use room::{Room, RoomName}; pub use room::{Room, RoomName};
pub use room_member::RoomMember; pub use room_member::RoomMember;

View File

@ -172,7 +172,7 @@ pub struct Room {
/// This is helpful when using a `StateStore` to avoid multiple requests to /// This is helpful when using a `StateStore` to avoid multiple requests to
/// the server for messages. /// the server for messages.
#[cfg(feature = "messages")] #[cfg(feature = "messages")]
#[cfg_attr(docsrs, doc(cfg(feature = "messages")))] #[cfg_attr(feature = "docs", doc(cfg(messages)))]
#[serde(with = "super::message::ser_deser")] #[serde(with = "super::message::ser_deser")]
pub messages: MessageQueue, pub messages: MessageQueue,
/// A list of users that are currently typing. /// A list of users that are currently typing.
@ -656,7 +656,7 @@ impl Room {
/// ///
/// Returns true if `MessageQueue` was added to. /// Returns true if `MessageQueue` was added to.
#[cfg(feature = "messages")] #[cfg(feature = "messages")]
#[cfg_attr(docsrs, doc(cfg(feature = "messages")))] #[cfg_attr(feature = "docs", doc(cfg(messages)))]
pub fn handle_message(&mut self, event: &AnySyncMessageEvent) -> bool { pub fn handle_message(&mut self, event: &AnySyncMessageEvent) -> bool {
self.messages self.messages
.push(AnyPossiblyRedactedSyncMessageEvent::Regular(event.clone())) .push(AnyPossiblyRedactedSyncMessageEvent::Regular(event.clone()))
@ -669,7 +669,7 @@ impl Room {
/// whole redaction event is added to the `Unsigned` `redacted_because` /// whole redaction event is added to the `Unsigned` `redacted_because`
/// field. /// field.
#[cfg(feature = "messages")] #[cfg(feature = "messages")]
#[cfg_attr(docsrs, doc(cfg(feature = "messages")))] #[cfg_attr(feature = "docs", doc(cfg(messages)))]
pub fn handle_redaction(&mut self, redacted_event: &SyncRedactionEvent) -> bool { pub fn handle_redaction(&mut self, redacted_event: &SyncRedactionEvent) -> bool {
use crate::{identifiers::RoomVersionId, models::message::PossiblyRedactedExt}; use crate::{identifiers::RoomVersionId, models::message::PossiblyRedactedExt};