Publicly export Snapshot (and minor changes) #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
I'm making a crate (well, collection of crates) for reading and writing MCBE worlds, and wanted to abstract over the implementation of LevelDB with a generic parameter, bounded by a trait specifying the interface. This trait includes a Snapshot associated type, and when I went to implement the trait for DB... well,
rusty_leveldb::snapshot::Snapshot
isn't publicly exported.While I was at it, I looked for other visibility issues, and adjusted WriteBatch and DBIterator. The compiler also warned me about an issue in
mem_env.rs
.Changes
FileExt::unlock
inmem_env.rs
to avoid a potential conflict withstd::fs::File::unlock
once the latter becomes stable. (File::unlock
is/will be an inherent method, not a method from a trait, so it'd win the conflict.)Snapshot
, accessible asrusty_leveldb::Snapshot
.new()
constructor of WriteBatch public (it was already publicly reachable anyway, asWriteBatch::default()
).WriteBatch::clear
leave 12 header bytes set to zero, in line withWriteBatch::new
, to ensure that the preceding calls toput
ordelete
are cleared, and followingput
s anddelete
s can be performed. If this didn't count as a bug fix, it could require a larger version bump if semver were followed more strictly, but previouslyWriteBatch::clear
would prevent following operations on it (except forWriteBatch::set_contents
) from working properly; AFAICT there can't be any existing usages ofWriteBatch::clear
that would break which weren't already broken.WriteBatch::clear
indb_impl.rs
, which would precede a call toWriteBatch::set_contents
in a following loop iteration.set_contents
already clears the Vec inside WriteBatch, soclear
did and does nothing there.DBIterator::new
to not be visible outside the crate, since one of the arguments tonew
(MergingIter
) isn't publicly exported, and isn't returned from a publicly exported function (at least among what docs.rs can see).Notes
I don't know why
SkipMap
is publicly exported. But I don't think anyone outside the crate would be able to use SkipMap for anything. Might as well leave it to avoid the breaking change of removing it, but the next time the major version number is bumped, SkipMap should probably be limited to within the crate.