Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
## 2020-02-02, Version 1.0.0
### Commits
- [[`3de8d37a0c`](https://github.com/datrs/random-access-disk/commit/3de8d37a0c33bc15874de8870734bbdd07a8b24c)] 1.0.0 (substack)
- [[`2fca3428a6`](https://github.com/datrs/random-access-disk/commit/2fca3428a6ca6e484c5b31c8b62422553641731e)] Merge pull request #28 from bltavares/bump-deps (Szabolcs Berecz)
- [[`bebe8b4a2c`](https://github.com/datrs/random-access-disk/commit/bebe8b4a2c95dcd6d19c54ceb2fe854799af4ea4)] Update code to editio 2018 (Bruno Tavares)
- [[`310dd8a5d7`](https://github.com/datrs/random-access-disk/commit/310dd8a5d79e2edcfbded8cb48a17c5949c6b276)] Bump random-access-storage to 3.0.0 (Bruno Tavares)
- [[`95c3dad271`](https://github.com/datrs/random-access-disk/commit/95c3dad2715ade75c18337bb72f109573c9c08e3)] updated to use u64 (substack)
- [[`1d884a4432`](https://github.com/datrs/random-access-disk/commit/1d884a443232528c2a0a9e03901cb12eca137ac1)] sync_all implementation (substack)
- [[`bd9d0f6a86`](https://github.com/datrs/random-access-disk/commit/bd9d0f6a869d9f8225ae8582a5bfe5db6ca52578)] Update mkdirp requirement from 0.1.0 to 1.0.0 (dependabot-preview[bot])
- [[`f9b34735e7`](https://github.com/datrs/random-access-disk/commit/f9b34735e79020ff2f39bef510026f5cf8bf02b3)] Update quickcheck requirement from 0.7.2 to 0.8.0 (dependabot[bot])
- [[`4785a3dfa5`](https://github.com/datrs/random-access-disk/commit/4785a3dfa5aed164df833eafaeef4edda0dfd2c4)] Update changelog (Yoshua Wuyts)

### Stats
```diff
CHANGELOG.md | 16 ++++++-
Cargo.toml | 25 ++++-----
fuzz/Cargo.toml | 1 +-
fuzz/fuzz_targets/fuzz_target_1.rs | 6 +--
src/lib.rs | 109 ++++++++++++++++++++++++--------------
tests/model.rs | 34 ++++--------
tests/regression.rs | 5 +--
tests/test.rs | 82 +++++++++++++++++++++++++++--
8 files changed, 194 insertions(+), 84 deletions(-)
```


## 2018-12-20, Version 0.8.0
### Commits
- [[`c7cdc2d39a`](https://github.com/datrs/random-access-disk/commit/c7cdc2d39a7d92103f7125c28d2451ecf6272578)] (cargo-release) version 0.8.0 (Yoshua Wuyts)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version = "1.0.0"
edition = "2018"

[dependencies]
failure = "0.1.6"
anyhow = "1.0.26"
mkdirp = "1.0.0"
random-access-storage = "3.0.0"

Expand Down
24 changes: 13 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![cfg_attr(feature = "nightly", doc(include = "../README.md"))]
#![cfg_attr(test, deny(warnings))]

use failure::{ensure, Error};
use anyhow::{anyhow, Error};
use random_access_storage::RandomAccess;
use std::fs::{self, OpenOptions};
use std::io::{Read, Seek, SeekFrom, Write};
Expand Down Expand Up @@ -31,7 +31,7 @@ impl RandomAccessDisk {
}

impl RandomAccess for RandomAccessDisk {
type Error = Error;
type Error = Box<dyn std::error::Error + Sync + Send>;

fn write(&mut self, offset: u64, data: &[u8]) -> Result<(), Self::Error> {
let mut file = self.file.as_ref().expect("self.file was None.");
Expand Down Expand Up @@ -59,15 +59,17 @@ impl RandomAccess for RandomAccessDisk {
// reflect the state of the world.
// #[cfg_attr(test, allow(unused_io_amount))]
fn read(&mut self, offset: u64, length: u64) -> Result<Vec<u8>, Self::Error> {
ensure!(
(offset + length) as u64 <= self.length,
format!(
"Read bounds exceeded. {} < {}..{}",
self.length,
offset,
offset + length
)
);
if (offset + length) as u64 > self.length {
return Err(
anyhow!(
"Read bounds exceeded. {} < {}..{}",
self.length,
offset,
offset + length
)
.into(),
);
}

let mut file = self.file.as_ref().expect("self.file was None.");
let mut buffer = vec![0; length as usize];
Expand Down