Better rustfmt

This commit is contained in:
adria0 2020-08-12 09:55:13 +02:00
parent afa748c08c
commit fd18f67e43
11 changed files with 63 additions and 40 deletions

15
.github/workflows/rustfmt.yaml vendored Normal file
View File

@ -0,0 +1,15 @@
name: Rustfmt
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install rustfmt
run: rustup component add rustfmt
- name: Check style
run: cargo fmt --all -- --check --config=merge_imports=true

View File

@ -6,22 +6,24 @@ extern crate crossbeam;
extern crate regex; extern crate regex;
extern crate structopt; extern crate structopt;
use std::fmt::Debug; use std::{fmt::Debug, io::prelude::*};
use std::io::prelude::*;
use async_std::io::Read; use async_std::{
use async_std::net::{TcpStream, UdpSocket}; io::Read,
net::{TcpStream, UdpSocket},
};
use kuska_handshake::async_std::{handshake_client, BoxStream}; use kuska_handshake::async_std::{handshake_client, BoxStream};
use kuska_ssb::api::{ use kuska_ssb::{
dto::{CreateHistoryStreamIn, CreateStreamIn, LatestOut, WhoAmIOut}, api::{
ApiCaller, dto::{CreateHistoryStreamIn, CreateStreamIn, LatestOut, WhoAmIOut},
ApiCaller,
},
discovery::ssb_net_id,
feed::{is_privatebox, privatebox_decipher, Feed, Message},
keystore::{from_patchwork_local, OwnedIdentity},
rpc::{RecvMsg, RequestNo, RpcReader, RpcWriter},
}; };
use kuska_ssb::discovery::ssb_net_id;
use kuska_ssb::feed::{is_privatebox, privatebox_decipher, Feed, Message};
use kuska_ssb::keystore::from_patchwork_local;
use kuska_ssb::keystore::OwnedIdentity;
use kuska_ssb::rpc::{RecvMsg, RequestNo, RpcReader, RpcWriter};
use regex::Regex; use regex::Regex;
use sodiumoxide::crypto::sign::ed25519; use sodiumoxide::crypto::sign::ed25519;

View File

@ -1,9 +1,10 @@
use crate::feed::Message; use crate::{
use crate::rpc::{Body, BodyType, RequestNo, RpcType, RpcWriter}; feed::Message,
rpc::{Body, BodyType, RequestNo, RpcType, RpcWriter},
};
use async_std::io::Write; use async_std::io::Write;
use super::dto; use super::{dto, error::Result};
use super::error::Result;
const MAX_RPC_BODY_LEN: usize = 65536; const MAX_RPC_BODY_LEN: usize = 65536;

View File

@ -5,5 +5,4 @@ pub use error::{Error, Result};
pub use sodium::{ pub use sodium::{
ToSodiumObject, ToSsbId, CURVE_ED25519_SUFFIX, ED25519_SIGNATURE_SUFFIX, SHA256_SUFFIX, ToSodiumObject, ToSsbId, CURVE_ED25519_SUFFIX, ED25519_SIGNATURE_SUFFIX, SHA256_SUFFIX,
}; };
pub use sodiumoxide::crypto::hash::sha256; pub use sodiumoxide::crypto::{hash::sha256, sign::ed25519};
pub use sodiumoxide::crypto::sign::ed25519;

View File

@ -1,5 +1,4 @@
use sodiumoxide::crypto::hash::sha256; use sodiumoxide::crypto::{hash::sha256, sign::ed25519};
use sodiumoxide::crypto::sign::ed25519;
use super::error::{Error, Result}; use super::error::{Error, Result};

View File

@ -10,7 +10,7 @@ use async_std::net::{IpAddr, SocketAddr, UdpSocket};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use crate::{crypto::ed25519, crypto::ToSodiumObject}; use crate::crypto::{ed25519, ToSodiumObject};
use super::error::{Error, Result}; use super::error::{Error, Result};

View File

@ -1,10 +1,11 @@
use serde_json::Value; use serde_json::Value;
use super::error::{Error, Result}; use super::{
use super::message::Message; error::{Error, Result},
use super::ssb_sha256; message::Message,
use std::time::SystemTime; ssb_sha256,
use std::time::UNIX_EPOCH; };
use std::time::{SystemTime, UNIX_EPOCH};
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct Feed { pub struct Feed {

View File

@ -1,13 +1,13 @@
use std::str::FromStr; use std::{str::FromStr, time::SystemTime};
use std::time::SystemTime;
use serde_json::Value; use serde_json::Value;
use sodiumoxide::crypto::sign::ed25519; use sodiumoxide::crypto::sign::ed25519;
use super::error::{Error, Result}; use super::{
use super::{ssb_sha256, stringify_json}; error::{Error, Result},
use crate::crypto::ToSodiumObject; ssb_sha256, stringify_json,
use crate::keystore::OwnedIdentity; };
use crate::{crypto::ToSodiumObject, keystore::OwnedIdentity};
use sodiumoxide::crypto::hash::sha256; use sodiumoxide::crypto::hash::sha256;
const MSG_PREVIOUS: &str = "previous"; const MSG_PREVIOUS: &str = "previous";

View File

@ -1,7 +1,10 @@
use crate::crypto::ToSodiumObject; use crate::crypto::ToSodiumObject;
use sodiumoxide::crypto::sign::SecretKey; use sodiumoxide::crypto::{
use sodiumoxide::crypto::{scalarmult::curve25519, secretbox, sign::ed25519}; scalarmult::curve25519,
secretbox,
sign::{ed25519, SecretKey},
};
use super::error::{Error, Result}; use super::error::{Error, Result};

View File

@ -1,10 +1,14 @@
use async_std::io::{Read, Write}; use async_std::{
use async_std::prelude::*; io::{Read, Write},
prelude::*,
};
use std::string::ToString; use std::string::ToString;
use super::error::{Error, Result}; use super::{
use super::OwnedIdentity; error::{Error, Result},
OwnedIdentity,
};
use crate::crypto::{ToSodiumObject, ToSsbId}; use crate::crypto::{ToSodiumObject, ToSsbId};
use serde_json::to_vec_pretty; use serde_json::to_vec_pretty;

View File

@ -1,7 +1,6 @@
use super::error::{Error, Result}; use super::error::{Error, Result};
use async_std::io; use async_std::{io, prelude::*};
use async_std::prelude::*;
use log::{trace, warn}; use log::{trace, warn};
use async_stream::stream; use async_stream::stream;