Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
a-moreira committed Jul 6, 2023
1 parent e8f9924 commit 7b60577
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 30 deletions.
5 changes: 1 addition & 4 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ use dialoguer::Input;
use futures::{future::Either, Future, FutureExt};
use indicatif::{MultiProgress, ProgressBar};
use magic_wormhole::PgpWordList;
use std::{
io::Write,
path::{PathBuf},
};
use std::{io::Write, path::PathBuf};

use magic_wormhole::{
dilated_transfer, forwarding, transfer, transit, MailboxConnection, Wormhole,
Expand Down
6 changes: 2 additions & 4 deletions src/core/wordlist.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use rand::{rngs::OsRng, seq::SliceRandom};
use serde_json::{self};


use dialoguer::Completion;
use std::collections::HashMap;
use std::fs;
use std::{collections::HashMap, fs};

pub struct PgpWordList {
words: Vec<Vec<String>>,
Expand All @@ -14,7 +12,7 @@ pub struct PgpWordList {
impl PgpWordList {
pub fn choose_words(&self) -> String {
let mut rng = OsRng;

let components: Vec<String> = self
.words
.iter()
Expand Down
2 changes: 0 additions & 2 deletions src/dilation/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ pub struct ManagerMachine {
#[cfg_attr(test, automock)]
impl ManagerMachine {
pub fn new(side: MySide) -> Self {

ManagerMachine {
side,
role: Role::Follower,
Expand Down Expand Up @@ -184,7 +183,6 @@ impl ManagerMachine {
"processing event finished: state={}, command={}",
self.state.unwrap(),
command

.map(|cmd| cmd.to_string())
.unwrap_or("n/a".to_string())
);
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ pub mod uri;

pub use crate::core::{
key::{GenericKey, Key, KeyPurpose, WormholeKey},
rendezvous,
wordlist::PgpWordList,
rendezvous, AppConfig, AppID, Code, MailboxConnection, Mood, Nameplate, Wormhole,
WormholeError,
AppConfig, AppID, Code, MailboxConnection, Mood, Nameplate, Wormhole, WormholeError,
};

#[cfg(feature = "dilation")]
Expand Down
34 changes: 16 additions & 18 deletions src/transfer/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ async fn make_transit(

/* Send our transit hints */
wormhole
.send_json(&PeerMessage::transit_v2(
(**connector.our_hints()).clone(),
))
.send_json(&PeerMessage::transit_v2((**connector.our_hints()).clone()))
.await?;

/* Receive their transit hints */
Expand Down Expand Up @@ -210,7 +208,7 @@ async fn send_inner(
) -> Result<(), TransferError> {
transit.send_record(&{
/* This must be split into two statements to appease the borrow checker (unfortunate side effect of borrow-through) */

PeerMessageV2::Offer((&offer).into()).ser_msgpack()
}).await?;

Expand Down Expand Up @@ -585,20 +583,20 @@ async fn receive_inner(
};
}

let _transfer_ack = match PeerMessageV2::de_msgpack(&transit.receive_record().await?)?
.check_err()?
{
PeerMessageV2::TransferAck(transfer_ack) => transfer_ack,
PeerMessageV2::FileStart(_) => {
bail!(TransferError::Protocol(
"Unexpected message: got 'file-start' but did not expect any more files".to_string()
.into_boxed_str()
))
},
other => {
bail!(TransferError::unexpected_message("transfer-ack", other))
},
};
let _transfer_ack =
match PeerMessageV2::de_msgpack(&transit.receive_record().await?)?.check_err()? {
PeerMessageV2::TransferAck(transfer_ack) => transfer_ack,
PeerMessageV2::FileStart(_) => {
bail!(TransferError::Protocol(
"Unexpected message: got 'file-start' but did not expect any more files"
.to_string()
.into_boxed_str()
))
},
other => {
bail!(TransferError::unexpected_message("transfer-ack", other))
},
};

Ok(())
}

0 comments on commit 7b60577

Please sign in to comment.