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::Snapshotisn'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::unlockinmem_env.rsto avoid a potential conflict withstd::fs::File::unlockonce the latter becomes stable. (File::unlockis/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::clearleave 12 header bytes set to zero, in line withWriteBatch::new, to ensure that the preceding calls toputordeleteare cleared, and followingputs anddeletes 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::clearwould prevent following operations on it (except forWriteBatch::set_contents) from working properly; AFAICT there can't be any existing usages ofWriteBatch::clearthat would break which weren't already broken.WriteBatch::clearindb_impl.rs, which would precede a call toWriteBatch::set_contentsin a following loop iteration.set_contentsalready clears the Vec inside WriteBatch, socleardid and does nothing there.DBIterator::newto 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
SkipMapis 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.