style: Remove usage of assign! macro from examples

This commit is contained in:
Jonas Platte
2022-06-07 17:12:36 +02:00
committed by Jonas Platte
parent 0e206506d9
commit 445b2e627d
2 changed files with 12 additions and 20 deletions
@@ -15,20 +15,18 @@ async fn bootstrap(client: Client, user_id: OwnedUserId, password: String) {
io::stdin().read_line(&mut input).expect("error: unable to read user input");
if let Err(e) = client.encryption().bootstrap_cross_signing(None).await {
use matrix_sdk::ruma::{api::client::uiaa, assign};
use matrix_sdk::ruma::api::client::uiaa;
if let Some(response) = e.uiaa_response() {
let auth_data = uiaa::AuthData::Password(assign!(
uiaa::Password::new(
uiaa::UserIdentifier::UserIdOrLocalpart(user_id.as_str()),
&password,
),
{ session: response.session.as_deref() }
));
let mut password = uiaa::Password::new(
uiaa::UserIdentifier::UserIdOrLocalpart(user_id.as_str()),
&password,
);
password.session = response.session.as_deref();
client
.encryption()
.bootstrap_cross_signing(Some(auth_data))
.bootstrap_cross_signing(Some(uiaa::AuthData::Password(password)))
.await
.expect("Couldn't bootstrap cross signing")
} else {
+5 -11
View File
@@ -6,8 +6,7 @@ use matrix_sdk::{
config::SyncSettings,
room::Room,
ruma::{
api::client::filter::{FilterDefinition, LazyLoadOptions, RoomEventFilter, RoomFilter},
assign,
api::client::filter::{FilterDefinition, LazyLoadOptions},
events::{AnySyncMessageLikeEvent, AnySyncRoomEvent, SyncMessageLikeEvent},
},
store::make_store_config,
@@ -73,15 +72,10 @@ async fn main() -> anyhow::Result<()> {
let client = login(homeserver_url, &username, &password).await;
let room_event_filter = assign!(RoomEventFilter::default(), {
lazy_load_options: LazyLoadOptions::Enabled {include_redundant_members: false},
});
let filter = assign!(FilterDefinition::default(), {
room: assign!(RoomFilter::empty(), {
include_leave: true,
state: room_event_filter,
}),
});
let mut filter = FilterDefinition::default();
filter.room.include_leave = true;
filter.room.state.lazy_load_options =
LazyLoadOptions::Enabled { include_redundant_members: false };
let sync_settings = SyncSettings::new().timeout(Duration::from_secs(30)).filter(filter.into());
let (sender, receiver) = oneshot::channel::<()>();