#[non_exhaustive]pub enum MemoryStrategy {
Bounded,
Auto,
Mirrored,
}Expand description
How much memory a read-write open may use to hold the file being edited.
The two read-write backends differ in memory, not in what they can express: a bounded session reads through a handle and holds only what a commit is building, while a mirrored session materializes the whole file in memory. Bounded is the better default when it applies, but it cannot yet edit every file — a pre-v2 (non-latest-format) superblock or a userblock still needs the mirror.
This is what a caller says about that trade-off, on
FileAccessProperties::with_memory_strategy.
Leaving it unset lets the entry point decide: File::open_rw
prefers the bounded engine and falls back to the mirror (Auto),
while the deprecated File::open_rw_bounded
refuses instead of falling back (Bounded).
This is a request, so it is deliberately not the type a file answers with:
File::edit_backing returns an EditBacking,
which cannot express Auto.
Sealed: unlike FileLocking or FileSpaceStrategy,
whose variant sets mirror a closed C-library enum, this is a policy this crate
invented, so a fourth strategy must not be a breaking change.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bounded
Never build a whole-file mirror. A file the bounded engine cannot edit is
refused at open with Error::EditUnsupported, before anything is
staged. This is what
File::open_rw_bounded has always done.
Auto
Prefer the bounded engine, but fall back to the whole-file mirror for a
file it cannot edit, rather than refusing. Memory then scales with the
file, which is the cost of the file opening at all. What
File::open_rw uses when nothing is asked for.
Mirrored
Always build the whole-file mirror, whatever the file looks like. What
File::open_rw did before it learned to dispatch.
Trait Implementations§
Source§impl Clone for MemoryStrategy
impl Clone for MemoryStrategy
Source§fn clone(&self) -> MemoryStrategy
fn clone(&self) -> MemoryStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MemoryStrategy
Source§impl Debug for MemoryStrategy
impl Debug for MemoryStrategy
impl Eq for MemoryStrategy
Source§impl From<EditBacking> for MemoryStrategy
impl From<EditBacking> for MemoryStrategy
Source§fn from(backing: EditBacking) -> Self
fn from(backing: EditBacking) -> Self
Turns an outcome back into the request that pins it, so a caller can
reopen a file onto the backing it got the first time:
with_memory_strategy(file.edit_backing().unwrap().into()).
Source§impl PartialEq for MemoryStrategy
impl PartialEq for MemoryStrategy
impl StructuralPartialEq for MemoryStrategy
Auto Trait Implementations§
impl Freeze for MemoryStrategy
impl RefUnwindSafe for MemoryStrategy
impl Send for MemoryStrategy
impl Sync for MemoryStrategy
impl Unpin for MemoryStrategy
impl UnsafeUnpin for MemoryStrategy
impl UnwindSafe for MemoryStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more