Commit 03f1f2dc authored by Éloïs's avatar Éloïs
Browse files

[style] comply to latest clippy version

parent d3b02a3a
......@@ -450,6 +450,7 @@ impl DbTx {
}
}
#[allow(clippy::upper_case_acronyms)]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
struct HeadWS2Pv1ConfStringified {
......
......@@ -39,7 +39,7 @@ pub(crate) fn write_and_compress_bytes_in_file(
) -> Result<(), std::io::Error> {
let file = File::create(file_path)?;
let mut e = ZlibEncoder::new(file, compression);
e.write_all(&datas[..])?;
e.write_all(datas)?;
e.finish()?;
Ok(())
......
......@@ -39,8 +39,7 @@ fn gen_webstart_args(args: &DuniterWebstartArgs, duniter_ts_args: &mut Vec<Strin
}
pub(crate) fn gen_duniter_ts_args(args: &DuniterArgs, duniter_js_exe: String) -> Vec<String> {
let mut duniter_ts_args = Vec::new();
duniter_ts_args.push(duniter_js_exe);
let mut duniter_ts_args = vec![duniter_js_exe];
if let Some(ref home) = args.home {
duniter_ts_args.push("--home".to_owned());
duniter_ts_args.push(home.to_str().expect("invalid home path").to_owned());
......
......@@ -13,6 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#![allow(clippy::upper_case_acronyms)]
#![deny(
clippy::unwrap_used,
missing_debug_implementations,
......
......@@ -67,7 +67,7 @@ mod tests {
fn write_bin_file(file_path: &Path, datas: &[u8]) -> Result<(), std::io::Error> {
let mut file = std::fs::File::create(file_path)?;
file.write_all(&datas[..])?;
file.write_all(datas)?;
Ok(())
}
......
......@@ -26,5 +26,5 @@ use dubp::crypto::hashs::Hash;
use duniter_dbs::{databases::bc_v2::BcV2DbReadable, kv_typed::prelude::*, HashKeyV2};
pub fn tx_exist<BcDb: BcV2DbReadable>(bc_db_ro: &BcDb, hash: Hash) -> KvResult<bool> {
Ok(bc_db_ro.txs_hashs().contains_key(&HashKeyV2(hash))?)
bc_db_ro.txs_hashs().contains_key(&HashKeyV2(hash))
}
......@@ -13,6 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#![allow(clippy::upper_case_acronyms)]
#![deny(
clippy::unwrap_used,
missing_copy_implementations,
......
......@@ -76,8 +76,8 @@ impl kv_typed::prelude::FromBytes for BlockDbV1 {
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes");
Ok(serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?)
serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))
}
}
......@@ -131,8 +131,7 @@ impl kv_typed::prelude::FromBytes for BlockDbV2 {
type Err = CorruptedBytes;
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
Ok(bincode::deserialize(&bytes)
.map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))?)
bincode::deserialize(&bytes).map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))
}
}
......@@ -145,7 +144,7 @@ impl ToDumpString for BlockDbV2 {
#[cfg(feature = "explorer")]
impl ExplorableValue for BlockDbV2 {
fn from_explorer_str(source: &str) -> Result<Self, FromExplorerValueErr> {
Ok(serde_json::from_str(source).map_err(|e| FromExplorerValueErr(e.into()))?)
serde_json::from_str(source).map_err(|e| FromExplorerValueErr(e.into()))
}
fn to_explorer_json(&self) -> KvResult<serde_json::Value> {
serde_json::to_value(self).map_err(|e| KvError::DeserError(e.into()))
......
......@@ -63,8 +63,8 @@ impl kv_typed::prelude::FromBytes for BlockHeadDbV1 {
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes");
Ok(serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?)
serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))
}
}
......
......@@ -62,7 +62,7 @@ impl kv_typed::prelude::FromBytes for BlockMetaV2 {
type Err = bincode::Error;
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
Ok(bincode::deserialize(bytes)?)
bincode::deserialize(bytes)
}
}
......@@ -75,8 +75,8 @@ impl ToDumpString for BlockMetaV2 {
#[cfg(feature = "explorer")]
impl ExplorableValue for BlockMetaV2 {
fn from_explorer_str(json_str: &str) -> std::result::Result<Self, FromExplorerValueErr> {
Ok(serde_json::from_str(&json_str)
.map_err(|e| FromExplorerValueErr(format!("{}: '{}'", e, json_str).into()))?)
serde_json::from_str(&json_str)
.map_err(|e| FromExplorerValueErr(format!("{}: '{}'", e, json_str).into()))
}
fn to_explorer_json(&self) -> KvResult<serde_json::Value> {
serde_json::to_value(self).map_err(|e| KvError::DeserError(e.into()))
......
......@@ -31,8 +31,8 @@ impl kv_typed::prelude::FromBytes for BlockNumberArrayV1 {
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes");
//println!("json_str='{}'", &json_str);
Ok(serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?)
serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))
}
}
......
......@@ -34,8 +34,8 @@ impl kv_typed::prelude::FromBytes for CIndexDbV1 {
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes");
//println!("json_str='{}'", &json_str);
Ok(serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?)
serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))
}
}
......
......@@ -103,8 +103,7 @@ impl kv_typed::prelude::FromBytes for DunpHeadDbV1 {
type Err = CorruptedBytes;
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
Ok(bincode::deserialize(&bytes)
.map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))?)
bincode::deserialize(&bytes).map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))
}
}
......
......@@ -31,7 +31,7 @@ impl kv_typed::prelude::FromBytes for IdtyDbV2 {
type Err = bincode::Error;
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
Ok(bincode::deserialize(bytes)?)
bincode::deserialize(bytes)
}
}
......
......@@ -31,8 +31,8 @@ impl kv_typed::prelude::FromBytes for IIndexDbV1 {
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes");
//println!("json_str='{}'", &json_str);
Ok(serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?)
serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))
}
}
......
......@@ -33,8 +33,8 @@ impl kv_typed::prelude::FromBytes for KickDbV1 {
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes");
Ok(serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?)
serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))
}
}
......
......@@ -31,8 +31,8 @@ impl kv_typed::prelude::FromBytes for MIndexDbV1 {
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes");
//println!("json_str='{}'", &json_str);
Ok(serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?)
serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))
}
}
......
......@@ -37,8 +37,7 @@ impl kv_typed::prelude::FromBytes for PeerCardDbV1 {
type Err = CorruptedBytes;
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
Ok(bincode::deserialize(&bytes)
.map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))?)
bincode::deserialize(&bytes).map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))
}
}
......
......@@ -54,8 +54,8 @@ impl kv_typed::prelude::FromBytes for SIndexDBV1 {
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
let json_str = std::str::from_utf8(bytes).expect("corrupted db : invalid utf8 bytes");
Ok(serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))?)
serde_json::from_str(&json_str)
.map_err(|e| CorruptedBytes(format!("{}: '{}'", e, json_str)))
}
}
......
......@@ -30,8 +30,7 @@ impl kv_typed::prelude::FromBytes for PendingTxDbV2 {
type Err = CorruptedBytes;
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, Self::Err> {
Ok(bincode::deserialize(&bytes)
.map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))?)
bincode::deserialize(&bytes).map_err(|e| CorruptedBytes(format!("{}: '{:?}'", e, bytes)))
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment