https://github.com/magiclen/same-content
Determine whether data from different sources are the same.
https://github.com/magiclen/same-content
rust
Last synced: 4 months ago
JSON representation
Determine whether data from different sources are the same.
- Host: GitHub
- URL: https://github.com/magiclen/same-content
- Owner: magiclen
- License: mit
- Created: 2020-08-12T14:05:33.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-09-11T03:19:56.000Z (almost 2 years ago)
- Last Synced: 2025-02-28T07:03:41.648Z (5 months ago)
- Topics: rust
- Language: Rust
- Homepage:
- Size: 886 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Same Content
====================[](https://github.com/magiclen/same-content/actions/workflows/ci.yml)
Determine whether data from different sources are the same.
## Example
```rust
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,
```rust
use std::fs::File;use same_content::*;
use same_content::generic_array::typenum::U4096;assert!(!same_content_from_files2::(&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.
```toml
[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](LICENSE)