From a1518857693bc1b95a1855904783c63743d9ee49 Mon Sep 17 00:00:00 2001 From: Nate Maninger Date: Wed, 6 Nov 2024 10:43:18 -0800 Subject: [PATCH] fmt --- sia/src/encoding/v1_encoding.rs | 36 ++++++++++++++++----------------- sia/src/encoding/v2_encoding.rs | 36 ++++++++++++++++----------------- sia/src/signing.rs | 17 ++++++++-------- sia/src/transactions.rs | 6 +++--- sia/src/unlock_conditions.rs | 3 +-- 5 files changed, 48 insertions(+), 50 deletions(-) diff --git a/sia/src/encoding/v1_encoding.rs b/sia/src/encoding/v1_encoding.rs index ae4f82d..59ece0d 100644 --- a/sia/src/encoding/v1_encoding.rs +++ b/sia/src/encoding/v1_encoding.rs @@ -52,26 +52,26 @@ impl V1SiaEncodable for [T] { } impl V1SiaEncodable for Option { - fn encode_v1(&self, w: &mut W) -> Result<()> { - match self { - Some(v) => { - true.encode_v1(w)?; - v.encode_v1(w) - } - None => false.encode_v1(w), - } - } + fn encode_v1(&self, w: &mut W) -> Result<()> { + match self { + Some(v) => { + true.encode_v1(w)?; + v.encode_v1(w) + } + None => false.encode_v1(w), + } + } } -impl V1SiaDecodable for Option { - fn decode_v1(r: &mut R) -> Result { - let has_value = bool::decode_v1(r)?; - if has_value { - Ok(Some(T::decode_v1(r)?)) - } else { - Ok(None) - } - } +impl V1SiaDecodable for Option { + fn decode_v1(r: &mut R) -> Result { + let has_value = bool::decode_v1(r)?; + if has_value { + Ok(Some(T::decode_v1(r)?)) + } else { + Ok(None) + } + } } macro_rules! impl_sia_numeric { diff --git a/sia/src/encoding/v2_encoding.rs b/sia/src/encoding/v2_encoding.rs index ad3254c..300536b 100644 --- a/sia/src/encoding/v2_encoding.rs +++ b/sia/src/encoding/v2_encoding.rs @@ -68,26 +68,26 @@ impl SiaEncodable for [T] { } impl SiaEncodable for Option { - fn encode(&self, w: &mut W) -> Result<()> { - match self { - Some(v) => { - true.encode(w)?; - v.encode(w) - } - None => false.encode(w), - } - } + fn encode(&self, w: &mut W) -> Result<()> { + match self { + Some(v) => { + true.encode(w)?; + v.encode(w) + } + None => false.encode(w), + } + } } -impl SiaDecodable for Option { - fn decode(r: &mut R) -> Result { - let has_value = bool::decode(r)?; - if has_value { - Ok(Some(T::decode(r)?)) - } else { - Ok(None) - } - } +impl SiaDecodable for Option { + fn decode(r: &mut R) -> Result { + let has_value = bool::decode(r)?; + if has_value { + Ok(Some(T::decode(r)?)) + } else { + Ok(None) + } + } } macro_rules! impl_sia_numeric { diff --git a/sia/src/signing.rs b/sia/src/signing.rs index 076c9c5..f6754ae 100644 --- a/sia/src/signing.rs +++ b/sia/src/signing.rs @@ -5,7 +5,8 @@ use crate::encoding::{SiaDecodable, SiaDecode, SiaEncodable, SiaEncode}; use crate::{ChainIndex, Hash256, HexParseError}; use base64::prelude::*; use ed25519_dalek::{Signature as ED25519Signature, Signer, SigningKey, Verifier, VerifyingKey}; -use serde::{de::Error, Deserialize, Serialize}; +use serde::de::Error; +use serde::{Deserialize, Serialize}; /// An ed25519 public key that can be used to verify a signature #[derive(Debug, PartialEq, Clone, Copy, SiaEncode, SiaDecode)] @@ -232,15 +233,13 @@ impl SigningState { mod tests { use std::vec; - use crate::{ - transactions::{ - CoveredFields, FileContract, FileContractID, FileContractRevision, SiacoinInput, - SiacoinOutput, SiafundInput, SiafundOutput, StorageProof, Transaction, - TransactionSignature, - }, - unlock_conditions::UnlockConditions, - Address, Currency, Leaf, + use crate::transactions::{ + CoveredFields, FileContract, FileContractID, FileContractRevision, SiacoinInput, + SiacoinOutput, SiafundInput, SiafundOutput, StorageProof, Transaction, + TransactionSignature, }; + use crate::unlock_conditions::UnlockConditions; + use crate::{Address, Currency, Leaf}; use super::*; diff --git a/sia/src/transactions.rs b/sia/src/transactions.rs index a06d82c..dfbe334 100644 --- a/sia/src/transactions.rs +++ b/sia/src/transactions.rs @@ -4,8 +4,7 @@ use crate::encoding::{ use crate::signing::{PrivateKey, SigningState}; use crate::specifier::{specifier, Specifier}; use crate::unlock_conditions::UnlockConditions; -use crate::Hash256; -use crate::{encoding, Address, Currency, Leaf}; +use crate::{encoding, Address, Currency, Hash256, Leaf}; use blake2b_simd::Params; use serde::{Deserialize, Serialize}; @@ -363,7 +362,8 @@ impl Transaction { // Create a helper module for base64 serialization mod base64 { - use base64::{engine::general_purpose::STANDARD, Engine}; + use base64::engine::general_purpose::STANDARD; + use base64::Engine; use serde::{Deserialize, Deserializer, Serializer}; pub fn serialize(v: &[u8], s: S) -> Result { diff --git a/sia/src/unlock_conditions.rs b/sia/src/unlock_conditions.rs index 0abed94..861259e 100644 --- a/sia/src/unlock_conditions.rs +++ b/sia/src/unlock_conditions.rs @@ -5,8 +5,7 @@ use crate::encoding::{ use crate::merkle::{Accumulator, LEAF_HASH_PREFIX}; use crate::signing::PublicKey; use crate::specifier::{specifier, Specifier}; -use crate::Address; -use crate::HexParseError; +use crate::{Address, HexParseError}; use blake2b_simd::Params; use core::fmt; use serde::de::Error;