Crates.io | same-content |
lib.rs | same-content |
version | 0.1.10 |
source | src |
created_at | 2020-08-12 14:08:00.309555 |
updated_at | 2023-09-11 03:20:02.932554 |
description | Determine whether data from different sources are the same. |
homepage | https://magiclen.org/same-content |
repository | https://github.com/magiclen/same-content |
max_upload_size | |
id | 275827 |
size | 10,518 |
Determine whether data from different sources are the same.
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());
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());
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.
https://crates.io/crates/same-content