Commit Graph

9 Commits

Author SHA1 Message Date
Jeremy Fitzhardinge
aeff388fef tp2: update rust-crates-io
Summary: Update to include num_cpu and blake2. Also update bincode to 1.0.0

Reviewed By: StanislavGlebik

Differential Revision: D7098292

fbshipit-source-id: 67793a6f458d50fc049781f34abaf313c8ff7a79
2018-02-27 09:27:19 -08:00
Jeremy Fitzhardinge
ac31713c84 rust: failure cleanup pass
Summary:
Don't use failure's bail!() and ensure!() macros.

Instead, failure_ext provides:
- bail_err!(err) - Converts its single parameter to the expected error and returns; ie `return Err(From::from(err));`
- bail_msg!(fmt, ...) - takes format string parameters and returns a `failure::err_msg()` error
- ensure_err!(), ensure_msg!() - corresponding changes

Also:
- remove all stray references to error-chain
- remove direct references to failure_derive (it's reexported via failure and failure_ext)
- replace uses of `Err(foo)?;` with `bail_err!()` (since `bail_err` unconditionally returns, but `Err(x)?` does not in principle, which can affect type inference)

Reviewed By: kulshrax

Differential Revision: D6507717

fbshipit-source-id: 635fb6f8c96d185b195dff171ea9c8db9e83af10
2017-12-07 14:10:17 -08:00
Arun Kulshreshtha
40339c1f89 Upgrade to Rust 1.22.1
Summary:
This diff upgrades the version of rustc in fbcode to version 1.22.1,
including the requisite third-party2 symlink updates for  the `rust` and
`rust-crates-io` projects, config.py changes in the third-party2 and
third-party-buck directories, and code fixes for Rust targets in common/rust
and scm/mononoke.

Reviewed By: jsgf

Differential Revision: D6489808

fbshipit-source-id: 48377ea937916beb7dae7a3806de1fce1e29dd24
2017-12-05 18:57:32 -08:00
Jeremy Fitzhardinge
dc5e78c1c1 rust: mass convert scm/mononoke/... to use failure
Summary:
Convert scm/mononoke to use failure, and update common/rust crates it depends on as well.

What it looks like is a lot of deleted code...

General strategy:
- common/rust/failure_ext adds some things that are in git failure that aren't yet in crates.io (`bail!` and `ensure!`, `Result<T, Error>`)
- everything returns `Result<T, failure::Error>`
- crates with real error get an error type, with a derived Fail implementation
  - replicate error-chain by defining an `enum ErrorKind` where the fields match the declared errors in the error! macro
- crates with dummy error-chain (no local errors) lose it
- `.chain_err()` -> `.context()` or `.with_context()`

So far the only place I've needed to extract an error is in a unit test.
Having a single unified error type has simplified a lot of things, and removed a lot of error type parameters, error conversion, etc, etc.

Reviewed By: sid0

Differential Revision: D6446584

fbshipit-source-id: 744640ca2997d4a85513c4519017f2e2e78a73f5
2017-12-05 18:11:13 -08:00
Arun Kulshreshtha
81ce6d1cd2 Make storage_types::Version's field public
Summary:
Implementations of various storage backends in Mononoke may need to access the raw value inside of a Version struct. Originally, the intention was to make Version a trait, with concrete implementations inside of each storage backend crate that could access private fields by virtue of being in the same crate. Now that we're using a single concrete Version implementation across all of Mononoke, this field needs to be made public to allow the storage backends to have the appropriate access.

I considered several alternatives here: for example, we could instead provide as `as_inner()` method to extract the value, or we could even make this method part of a separate trait that one needs to specifically import to get access to the Version's innards. But given that all of these approaches still amount to allowing public access to this field, I decided to start out with the simplest approach, and ask: //should we instead make this a method?//

Reviewed By: jsgf

Differential Revision: D6215854

fbshipit-source-id: b29e7f9c96b077a5805b7195f28ddb5d871dca35
2017-11-08 12:30:47 -08:00
Siddharth Agarwal
dfd53e9233 filekv: allow specifying a version during set
Summary:
This field is optional. We need to ensure in linknodes that the
version is always set to a fixed value so that linknode blobs written out to
disk are deterministic.

Reviewed By: jsgf

Differential Revision: D6214032

fbshipit-source-id: c1eea7bf28bb096c1d23165e1f50ff2dc6d21274
2017-11-02 13:10:56 -07:00
Siddharth Agarwal
acda30f2fb replace AsRef<Path> with Into<PathBuf> in a few spots
Summary:
We need ownership of the buffer in all of these cases, and
`AsRef<Path>` could potentially create unnecessary copies.

Reviewed By: jsgf

Differential Revision: D6214034

fbshipit-source-id: 806a87bfe3b125febaaaaf26c8b8dcac407de145
2017-11-02 13:10:56 -07:00
Siddharth Agarwal
10b1993ca0 factor out file-based key-value store from FileBookmarks
Summary:
This code is generally useful and will also be used for linknodes.

Note that I marked `filekv` as a copy of `filebookmarks` to preserve blame
info. Git doesn't track renames so this unfortunately won't be transferred to
the open source repo.

Reviewed By: farnz

Differential Revision: D6015776

fbshipit-source-id: 2c17e2440e25e6179dd71d16a87095ad1b346b49
2017-10-10 07:29:30 -07:00
Siddharth Agarwal
86f4489e7c move bookmarks::Version into a separate crate
Summary:
This Version type is going to form the basis for other key-value
stores like linknodes, so it needs to be moved into a separate crate.

I've chosen `storage_types` as the name because it seems to be the most obvious
candidate.

Reviewed By: jsgf

Differential Revision: D6015772

fbshipit-source-id: 52de7866d68fdec2a4908626679a6f08c5f73402
2017-10-10 07:29:30 -07:00