10 releases

0.1.10 Sep 11, 2023
0.1.9 Sep 11, 2023
0.1.8 Mar 18, 2022
0.1.7 Oct 23, 2021
0.1.1 Aug 12, 2020

#199 in Debugging

Download history 49/week @ 2024-07-29 12/week @ 2024-09-23 5/week @ 2024-09-30 2/week @ 2024-10-07

60 downloads per month
Used in mongo-file-center

MIT license

10KB
149 lines

Same Content

CI

Determine whether data from different sources are the same.

Example

use std::fs::File;

use same_content::*;

assert!(!same_content_from_files(&mut File::open("tests/data/P1140310.jpg").unwrap(), &mut File::open("tests/data/P1140558.jpg").unwrap()).unwrap());

Change the Buffer Size

The default buffer size for the same_content_from_files function and the same_content_from_readers function is 256 bytes per stream. If you want to change that, you can use the same_content_from_files2 function or the same_content_from_readers2 function, and define a length explicitly.

For example, to change the buffer size to 4096 bytes,

use std::fs::File;

use same_content::*;
use same_content::generic_array::typenum::U4096;

assert!(!same_content_from_files2::<U4096>(&mut File::open("tests/data/P1140310.jpg").unwrap(), &mut File::open("tests/data/P1140558.jpg").unwrap()).unwrap());

Asynchronous APIs

You may want to use async APIs with your async runtime. This crate supports tokio, currently.

[dependencies.same-content]
version = "*"
features = ["tokio"]

After enabling the async feature, the async functions are available.

Crates.io

https://crates.io/crates/same-content

Documentation

https://docs.rs/same-content

License

MIT

Dependencies

~0.2–6MB
~26K SLoC