Skip to main content

MemoryStrategy

Enum MemoryStrategy 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source§

fn clone(&self) -> MemoryStrategy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for MemoryStrategy

Source§

impl Debug for MemoryStrategy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for MemoryStrategy

Source§

impl From<EditBacking> for MemoryStrategy

Source§

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

Source§

fn eq(&self, other: &MemoryStrategy) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MemoryStrategy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.