diff --git a/src/accounts.rs b/src/accounts.rs index a93cd45c9..efaeb6c0b 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -1,3 +1,5 @@ +//! # Account manager module. + use std::collections::BTreeMap; use async_std::channel::{Receiver, Sender}; @@ -251,12 +253,13 @@ impl Accounts { } } - /// Unified event emitter. + /// Returns unified event emitter. pub async fn get_event_emitter(&self) -> EventEmitter { self.emitter.clone() } } +/// Unified event emitter for multiple accounts. #[derive(Debug, Clone)] pub struct EventEmitter { /// Aggregate stream of events from all accounts. @@ -324,6 +327,7 @@ impl async_std::stream::Stream for EventEmitter { pub const CONFIG_NAME: &str = "accounts.toml"; pub const DB_NAME: &str = "dc.db"; +/// Account manager configuration file. #[derive(Debug, Clone)] pub struct Config { file: PathBuf, @@ -398,7 +402,7 @@ impl Config { } /// Create a new account in the given root directory. - pub async fn new_account(&self, dir: &PathBuf) -> Result { + async fn new_account(&self, dir: &PathBuf) -> Result { let id = { let inner = &mut self.inner.write().await; let id = inner.next_id; @@ -438,7 +442,7 @@ impl Config { self.sync().await } - pub async fn get_account(&self, id: u32) -> Option { + async fn get_account(&self, id: u32) -> Option { self.inner .read() .await @@ -469,8 +473,9 @@ impl Config { } } +/// Configuration of a single account. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -pub struct AccountConfig { +struct AccountConfig { /// Unique id. pub id: u32, /// Root directory for all data for this account. diff --git a/src/aheader.rs b/src/aheader.rs index cc3ee2100..798bf6974 100644 --- a/src/aheader.rs +++ b/src/aheader.rs @@ -1,4 +1,4 @@ -//! # Autocrypt header module +//! # Autocrypt header module. //! //! Parse and create [Autocrypt-headers](https://autocrypt.org/en/latest/level1.html#the-autocrypt-header). diff --git a/src/blob.rs b/src/blob.rs index d81d6d1ee..cd32771b0 100644 --- a/src/blob.rs +++ b/src/blob.rs @@ -1,4 +1,4 @@ -//! # Blob directory management +//! # Blob directory management. use core::cmp::max; use std::ffi::OsStr; diff --git a/src/chat.rs b/src/chat.rs index e6245c480..2befb612b 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1,4 +1,4 @@ -//! # Chat module +//! # Chat module. use std::convert::{TryFrom, TryInto}; use std::str::FromStr; @@ -975,6 +975,7 @@ impl Chat { &self.name } + /// Returns profile image path for the chat. pub async fn get_profile_image(&self, context: &Context) -> Result> { if let Some(image_rel) = self.param.get(Param::ProfileImage) { if !image_rel.is_empty() { @@ -1989,6 +1990,7 @@ pub(crate) async fn marknoticed_chat_if_older_than( Ok(()) } +/// Marks all messages in the chat as noticed. pub async fn marknoticed_chat(context: &Context, chat_id: ChatId) -> Result<()> { // "WHERE" below uses the index `(state, hidden, chat_id)`, see get_fresh_msg_cnt() for reasoning // the additional SELECT statement may speed up things as no write-blocking is needed. @@ -2109,6 +2111,7 @@ pub async fn get_next_media( Ok(ret) } +/// Returns a vector of contact IDs for given chat ID. pub async fn get_chat_contacts(context: &Context, chat_id: ChatId) -> Result> { // Normal chats do not include SELF. Group chats do (as it may happen that one is deleted from a // groupchat but the chats stays visible, moreover, this makes displaying lists easier) @@ -2131,6 +2134,7 @@ pub async fn get_chat_contacts(context: &Context, chat_id: ChatId) -> Result Result<()> { let new_name = improve_single_line_input(new_name); /* the function only sets the names of group chats; normal chats get their names from the contacts */ @@ -2939,6 +2944,7 @@ pub async fn add_device_msg_with_importance( Ok(msg_id) } +/// Adds a message to device chat. pub async fn add_device_msg( context: &Context, label: Option<&str>, diff --git a/src/chatlist.rs b/src/chatlist.rs index 55cd3e087..c43b5b7ea 100644 --- a/src/chatlist.rs +++ b/src/chatlist.rs @@ -1,4 +1,4 @@ -//! # Chat list module +//! # Chat list module. use anyhow::{bail, ensure, Result}; diff --git a/src/color.rs b/src/color.rs index fd3e15275..fd7f868cf 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,4 +1,4 @@ -//! Implementation of Consistent Color Generation +//! Implementation of Consistent Color Generation. //! //! Consistent Color Generation is defined in XEP-0392. //! diff --git a/src/config.rs b/src/config.rs index 058db676a..ae6333f23 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,4 @@ -//! # Key-value configuration management +//! # Key-value configuration management. use anyhow::Result; use strum::{EnumProperty, IntoEnumIterator}; diff --git a/src/configure.rs b/src/configure.rs index 70196d816..3829a7a5b 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -1,4 +1,4 @@ -//! Email accounts autoconfiguration process module +//! Email accounts autoconfiguration process module. mod auto_mozilla; mod auto_outlook; diff --git a/src/constants.rs b/src/constants.rs index 821a1796a..5f1e990ba 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -1,4 +1,4 @@ -//! # Constants +//! # Constants. use deltachat_derive::{FromSql, ToSql}; use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; diff --git a/src/context.rs b/src/context.rs index e5658fcd4..152a3a114 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,4 +1,4 @@ -//! Context module +//! Context module. use std::collections::{BTreeMap, HashMap}; use std::ffi::OsString; diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index efa8fefd9..3c31246a8 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -1,3 +1,5 @@ +//! Internet Message Format reception pipeline. + use std::convert::TryFrom; use anyhow::{bail, ensure, format_err, Result}; diff --git a/src/dehtml.rs b/src/dehtml.rs index d8c63c5bf..7871312dd 100644 --- a/src/dehtml.rs +++ b/src/dehtml.rs @@ -1,4 +1,4 @@ -//! De-HTML +//! De-HTML. //! //! A module to remove HTML tags from the email text diff --git a/src/e2ee.rs b/src/e2ee.rs index 702e44dd0..ae7652b6d 100644 --- a/src/e2ee.rs +++ b/src/e2ee.rs @@ -335,7 +335,7 @@ fn has_decrypted_pgp_armor(input: &[u8]) -> bool { false } -/// Check if a MIME structure contains a multipart/report part. +/// Checks if a MIME structure contains a multipart/report part. /// /// As reports are often unencrypted, we do not reset the Autocrypt header in /// this case. diff --git a/src/ephemeral.rs b/src/ephemeral.rs index 854b04697..c8eab5c65 100644 --- a/src/ephemeral.rs +++ b/src/ephemeral.rs @@ -1,4 +1,4 @@ -//! # Ephemeral messages +//! # Ephemeral messages. //! //! Ephemeral messages are messages that have an Ephemeral-Timer //! header attached to them, which specifies time in seconds after diff --git a/src/events.rs b/src/events.rs index d2c269894..1a8a1826e 100644 --- a/src/events.rs +++ b/src/events.rs @@ -1,4 +1,4 @@ -//! # Events specification +//! # Events specification. use std::ops::Deref; diff --git a/src/format_flowed.rs b/src/format_flowed.rs index ff21b9bd0..30249ecbd 100644 --- a/src/format_flowed.rs +++ b/src/format_flowed.rs @@ -1,13 +1,13 @@ -///! # format=flowed support -///! -///! Format=flowed is defined in -///! [RFC 3676](https://tools.ietf.org/html/rfc3676). -///! -///! Older [RFC 2646](https://tools.ietf.org/html/rfc2646) is used -///! during formatting, i.e., DelSp parameter introduced in RFC 3676 -///! is assumed to be set to "no". -///! -///! For received messages, DelSp parameter is honoured. +//! # format=flowed support. +//! +//! Format=flowed is defined in +//! [RFC 3676](https://tools.ietf.org/html/rfc3676). +//! +//! Older [RFC 2646](https://tools.ietf.org/html/rfc2646) is used +//! during formatting, i.e., DelSp parameter introduced in RFC 3676 +//! is assumed to be set to "no". +//! +//! For received messages, DelSp parameter is honoured. /// Wraps line to 72 characters using format=flowed soft breaks. /// diff --git a/src/headerdef.rs b/src/headerdef.rs index 87dba1a4c..66f71e9a9 100644 --- a/src/headerdef.rs +++ b/src/headerdef.rs @@ -1,3 +1,5 @@ +//! # List of email headers. + use crate::strum::AsStaticRef; use mailparse::{MailHeader, MailHeaderMap}; diff --git a/src/html.rs b/src/html.rs index 13c479699..444e0f815 100644 --- a/src/html.rs +++ b/src/html.rs @@ -1,11 +1,12 @@ -///! # Get message as HTML. -///! -///! Use `Message.has_html()` to check if the UI shall render a -///! corresponding button and `MsgId.get_html()` to get the full message. -///! -///! Even when the original mime-message is not HTML, -///! `MsgId.get_html()` will return HTML - -///! this allows nice quoting, handling linebreaks properly etc. +//! # Get message as HTML. +//! +//! Use `Message.has_html()` to check if the UI shall render a +//! corresponding button and `MsgId.get_html()` to get the full message. +//! +//! Even when the original mime-message is not HTML, +//! `MsgId.get_html()` will return HTML - +//! this allows nice quoting, handling linebreaks properly etc. + use futures::future::FutureExt; use std::future::Future; use std::pin::Pin; diff --git a/src/imap.rs b/src/imap.rs index 6a2298a96..a3a9d306e 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -1,4 +1,4 @@ -//! # Imap handling module +//! # IMAP handling module. //! //! uses [async-email/async-imap](https://github.com/async-email/async-imap) //! to implement connect, fetch, delete functionality with standard IMAP servers. diff --git a/src/imex.rs b/src/imex.rs index 15292e66f..6969c354d 100644 --- a/src/imex.rs +++ b/src/imex.rs @@ -1,4 +1,4 @@ -//! # Import/export module +//! # Import/export module. use std::any::Any; use std::ffi::OsStr; @@ -66,15 +66,15 @@ pub enum ImexMode { /// Import/export things. /// -/// What to do is defined by the *what* parameter. +/// What to do is defined by the `what` parameter. /// /// During execution of the job, /// some events are sent out: /// -/// - A number of #DC_EVENT_IMEX_PROGRESS events are sent and may be used to create +/// - A number of `DC_EVENT_IMEX_PROGRESS` events are sent and may be used to create /// a progress bar or stuff like that. Moreover, you'll be informed when the imex-job is done. /// -/// - For each file written on export, the function sends #DC_EVENT_IMEX_FILE_WRITTEN +/// - For each file written on export, the function sends `DC_EVENT_IMEX_FILE_WRITTEN` /// /// Only one import-/export-progress can run at the same time. /// To cancel an import-/export-progress, drop the future returned by this function. @@ -204,6 +204,7 @@ pub async fn has_backup_old(context: &Context, dir_name: &Path) -> Result Result { use futures::future::FutureExt; @@ -435,7 +436,7 @@ async fn decrypt_setup_file( Ok(plain_text) } -pub fn normalize_setup_code(s: &str) -> String { +fn normalize_setup_code(s: &str) -> String { let mut out = String::new(); for c in s.chars() { if ('0'..='9').contains(&c) { diff --git a/src/job.rs b/src/job.rs index ba639593b..719ae725d 100644 --- a/src/job.rs +++ b/src/job.rs @@ -1,4 +1,4 @@ -//! # Job module +//! # Job module. //! //! This module implements a job queue maintained in the SQLite database //! and job types. diff --git a/src/key.rs b/src/key.rs index 6d05d48a2..b0b2742ef 100644 --- a/src/key.rs +++ b/src/key.rs @@ -1,4 +1,4 @@ -//! Cryptographic key module +//! Cryptographic key module. use std::collections::BTreeMap; use std::fmt; diff --git a/src/lib.rs b/src/lib.rs index e90ddd519..6d9220696 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +//! # Delta Chat Core Library. + #![forbid(unsafe_code)] #![deny( clippy::correctness, @@ -59,7 +61,7 @@ mod imap; pub mod imex; mod scheduler; #[macro_use] -pub mod job; +mod job; mod format_flowed; pub mod key; mod keyring; diff --git a/src/location.rs b/src/location.rs index e09e81202..b35c5d078 100644 --- a/src/location.rs +++ b/src/location.rs @@ -1,4 +1,4 @@ -//! Location handling +//! Location handling. use std::convert::TryFrom; use anyhow::{ensure, Error}; diff --git a/src/log.rs b/src/log.rs index 0dc9dc434..e8927b548 100644 --- a/src/log.rs +++ b/src/log.rs @@ -1,4 +1,5 @@ -//! # Logging +//! # Logging. + use crate::context::Context; #[macro_export] diff --git a/src/login_param.rs b/src/login_param.rs index 8a5c00056..cc377bb41 100644 --- a/src/login_param.rs +++ b/src/login_param.rs @@ -1,4 +1,4 @@ -//! # Login parameters +//! # Login parameters. use std::borrow::Cow; use std::fmt; diff --git a/src/lot.rs b/src/lot.rs index 805567ba0..02bf4df13 100644 --- a/src/lot.rs +++ b/src/lot.rs @@ -1,3 +1,5 @@ +//! # Legacy generic return values for C API. + use deltachat_derive::{FromSql, ToSql}; use crate::key::Fingerprint; diff --git a/src/message.rs b/src/message.rs index 8f5905624..ac9f70abf 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,4 +1,4 @@ -//! # Messages and their identifiers +//! # Messages and their identifiers. use std::collections::BTreeMap; use std::convert::TryInto; diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 58f989242..403f96dfe 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -1,3 +1,5 @@ +//! # MIME message production. + use std::convert::TryInto; use anyhow::{bail, ensure, format_err, Result}; diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 9978047a8..248b4a116 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -1,3 +1,5 @@ +//! # MIME message parsing module. + use std::collections::{HashMap, HashSet}; use std::future::Future; use std::pin::Pin; diff --git a/src/oauth2.rs b/src/oauth2.rs index 7bc327665..7c4d2418c 100644 --- a/src/oauth2.rs +++ b/src/oauth2.rs @@ -1,4 +1,4 @@ -//! OAuth 2 module +//! OAuth 2 module. use std::collections::HashMap; diff --git a/src/peerstate.rs b/src/peerstate.rs index 669f35bb5..560085364 100644 --- a/src/peerstate.rs +++ b/src/peerstate.rs @@ -1,4 +1,4 @@ -//! # [Autocrypt Peer State](https://autocrypt.org/level1.html#peer-state-management) module +//! # [Autocrypt Peer State](https://autocrypt.org/level1.html#peer-state-management) module. use std::collections::HashSet; use std::fmt; diff --git a/src/pgp.rs b/src/pgp.rs index ffd6575ea..5068ff7d6 100644 --- a/src/pgp.rs +++ b/src/pgp.rs @@ -1,4 +1,4 @@ -//! OpenPGP helper module using [rPGP facilities](https://github.com/rpgp/rpgp) +//! OpenPGP helper module using [rPGP facilities](https://github.com/rpgp/rpgp). use std::collections::{BTreeMap, HashSet}; use std::io; diff --git a/src/plaintext.rs b/src/plaintext.rs index f00f4ed19..9b49a5483 100644 --- a/src/plaintext.rs +++ b/src/plaintext.rs @@ -1,4 +1,5 @@ -///! Handle plain text together with some attributes. +//! Handle plain text together with some attributes. + use crate::simplify::split_lines; use once_cell::sync::Lazy; diff --git a/src/provider.rs b/src/provider.rs index 54c2f7f03..1c094ef52 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -1,4 +1,4 @@ -//! [Provider database](https://providers.delta.chat/) module +//! [Provider database](https://providers.delta.chat/) module. mod data; diff --git a/src/qr.rs b/src/qr.rs index 866df1fdd..25432a7e4 100644 --- a/src/qr.rs +++ b/src/qr.rs @@ -1,4 +1,4 @@ -//! # QR code module +//! # QR code module. use anyhow::{bail, ensure, format_err, Error}; use once_cell::sync::Lazy; diff --git a/src/quota.rs b/src/quota.rs index c9a49d601..ca35ca30a 100644 --- a/src/quota.rs +++ b/src/quota.rs @@ -1,3 +1,5 @@ +//! # Support for IMAP QUOTA extension. + use anyhow::{anyhow, Result}; use async_imap::types::{Quota, QuotaResource}; use indexmap::IndexMap; diff --git a/src/securejoin.rs b/src/securejoin.rs index bdb56a131..ef47fdf5d 100644 --- a/src/securejoin.rs +++ b/src/securejoin.rs @@ -1,4 +1,4 @@ -//! Verified contact protocol implementation as [specified by countermitm project](https://countermitm.readthedocs.io/en/stable/new.html#setup-contact-protocol) +//! Verified contact protocol implementation as [specified by countermitm project](https://countermitm.readthedocs.io/en/stable/new.html#setup-contact-protocol). use std::convert::TryFrom; use std::time::{Duration, Instant}; diff --git a/src/simplify.rs b/src/simplify.rs index b4096a80e..faa3b76f5 100644 --- a/src/simplify.rs +++ b/src/simplify.rs @@ -1,3 +1,5 @@ +//! # Simplify incoming plaintext. + use itertools::Itertools; // protect lines starting with `--` against being treated as a footer. @@ -241,9 +243,7 @@ fn render_message(lines: &[&str], is_cut_at_end: bool) -> String { ret.replace("\u{200B}", "") } -/** - * Tools - */ +/// Returns true if the line contains only whitespace. fn is_empty_line(buf: &str) -> bool { buf.chars().all(char::is_whitespace) // for some time, this checked for `char <= ' '`, diff --git a/src/smtp.rs b/src/smtp.rs index c1556ab10..7bf2f7e67 100644 --- a/src/smtp.rs +++ b/src/smtp.rs @@ -1,4 +1,4 @@ -//! # SMTP transport module +//! # SMTP transport module. pub mod send; diff --git a/src/sql.rs b/src/sql.rs index 952fbf188..2bdd09440 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -1,4 +1,4 @@ -//! # SQLite wrapper +//! # SQLite wrapper. use async_std::path::Path; use async_std::sync::RwLock; diff --git a/src/sql/migrations.rs b/src/sql/migrations.rs index 734b8fbc3..f50100682 100644 --- a/src/sql/migrations.rs +++ b/src/sql/migrations.rs @@ -1,3 +1,5 @@ +//! Migrations module. + use anyhow::Result; use crate::config::Config; diff --git a/src/stock_str.rs b/src/stock_str.rs index aae80ded4..f0489c8e5 100644 --- a/src/stock_str.rs +++ b/src/stock_str.rs @@ -1,4 +1,4 @@ -//! Module to work with translatable stock strings +//! Module to work with translatable stock strings. use std::future::Future; use std::pin::Pin; diff --git a/src/token.rs b/src/token.rs index 99c5edaba..e4f9a4ff8 100644 --- a/src/token.rs +++ b/src/token.rs @@ -1,4 +1,4 @@ -//! # Token module +//! # Token module. //! //! Functions to read/write token from/to the database. A token is any string associated with a key. //!