mirror of
https://github.com/darakian/ddh.git
synced 2026-09-10 07:06:21 -04:00
Merge pull request #33 from darakian/impl-serialize-for-FileInfo
Remove serde-derive
This commit is contained in:
commit
7035276acd
|
|
@ -15,7 +15,6 @@ clap = "2.33.0"
|
|||
rayon = "1.3"
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
serde_derive = "1.0"
|
||||
siphasher = "0.3"
|
||||
nohash-hasher = "0.1.1"
|
||||
|
||||
|
|
|
|||
18
src/lib.rs
18
src/lib.rs
|
|
@ -9,7 +9,7 @@ use std::fs::{self, DirEntry};
|
|||
use std::io::{Read};
|
||||
use std::path::{PathBuf, Path};
|
||||
use std::cmp::Ordering;
|
||||
use serde_derive::{Serialize};
|
||||
use serde::ser::{Serialize, Serializer, SerializeStruct};
|
||||
use siphasher::sip128::Hasher128;
|
||||
use rayon::prelude::*;
|
||||
use std::sync::mpsc::{Sender, channel};
|
||||
|
|
@ -31,7 +31,7 @@ enum ChannelPackage{
|
|||
}
|
||||
|
||||
/// Serializable struct containing entries for a specific file. These structs will identify individual files as a collection of paths and associated hash and length data.
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug)]
|
||||
pub struct Fileinfo{
|
||||
full_hash: Option<u128>,
|
||||
partial_hash: Option<u128>,
|
||||
|
|
@ -179,6 +179,20 @@ impl Fileinfo{
|
|||
}
|
||||
}
|
||||
|
||||
impl Serialize for Fileinfo{
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let mut state = serializer.serialize_struct("Fileinfo", 4)?;
|
||||
state.serialize_field("partial_hash", &self.partial_hash)?;
|
||||
state.serialize_field("full_hash", &self.full_hash)?;
|
||||
state.serialize_field("file_length", &self.file_length)?;
|
||||
state.serialize_field("file_paths", &self.file_paths)?;
|
||||
state.end()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Fileinfo{
|
||||
fn eq(&self, other: &Fileinfo) -> bool {
|
||||
(self.file_length==other.file_length)&&
|
||||
|
|
|
|||
Loading…
Reference in a new issue