crypto: Improve doc of SAS accept settings

Document arguments explicitly.

Adapt to changed implementation.

Provide example call.
master
Jan Veen 2021-03-12 15:45:58 +01:00
parent 587c09e700
commit 42c8c42150
2 changed files with 22 additions and 2 deletions

View File

@ -33,7 +33,22 @@ impl Sas {
/// Accept the interactive verification flow with specific settings. /// Accept the interactive verification flow with specific settings.
/// ///
/// Pass `settings` to customizes the accept-request before sending it. /// # Arguments
///
/// * `settings` - specific customizations to the verification flow.
///
/// # Examples
///
/// ```ignore
/// use matrix_sdk::Sas;
/// use matrix_sdk_base::crypto::AcceptSettings;
/// use matrix_sdk::events::key::verification::ShortAuthenticationString;
///
/// let only_decimal = AcceptSettings::with_allowed_methods(
/// vec![ShortAuthenticationString::Decimal]
/// );
/// sas.accept_with_settings(only_decimal);
/// ```
pub async fn accept_with_settings(&self, settings: AcceptSettings) -> Result<()> { pub async fn accept_with_settings(&self, settings: AcceptSettings) -> Result<()> {
if let Some(req) = self.inner.accept_with_settings(settings) { if let Some(req) = self.inner.accept_with_settings(settings) {
match req { match req {

View File

@ -682,6 +682,7 @@ pub struct AcceptSettings {
} }
impl Default for AcceptSettings { impl Default for AcceptSettings {
/// All methods are allowed
fn default() -> Self { fn default() -> Self {
Self { Self {
allowed_methods: vec![ allowed_methods: vec![
@ -693,7 +694,11 @@ impl Default for AcceptSettings {
} }
impl AcceptSettings { impl AcceptSettings {
/// Create settings with exactly the specified SAS methods /// Create settings restricting the allowed SAS methods
///
/// # Arguments
///
/// * `methods` - The methods this client allows at most
pub fn with_allowed_methods(methods: Vec<ShortAuthenticationString>) -> Self { pub fn with_allowed_methods(methods: Vec<ShortAuthenticationString>) -> Self {
Self { Self {
allowed_methods: methods, allowed_methods: methods,