Skip to main content

PersistentFileMapped

Struct PersistentFileMapped 

Source
pub struct PersistentFileMapped<T>(/* private fields */);
Expand description

A FileMapped region that does not wipe pre-existing file contents when doublets grows it.

See the module documentation for the upstream behaviour this works around.

Implementations§

Source§

impl<T> PersistentFileMapped<T>

Source

pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>

Opens (creating it if needed) the file at path and maps it.

Source

pub fn new(file: File) -> Result<Self>

Maps an already-opened file.

Source

pub fn inner(&self) -> &FileMapped<T>

Borrows the wrapped FileMapped.

Trait Implementations§

Source§

impl<T: Debug> Debug for PersistentFileMapped<T>

Source§

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

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

impl<T> RawMem for PersistentFileMapped<T>

Source§

fn grow_filled( &mut self, cap: usize, value: Self::Item, ) -> MemResult<&mut [Self::Item]>
where Self::Item: Clone,

Fills only the genuinely uninitialised tail of the grown region, keeping the bytes that were already persisted in the file.

Source§

type Item = T

The element type stored in this memory.
Source§

fn allocated(&self) -> &[Self::Item]

Returns a shared slice of all currently initialized elements.
Source§

fn allocated_mut(&mut self) -> &mut [Self::Item]

Returns a mutable slice of all currently initialized elements.
Source§

unsafe fn grow( &mut self, addition: usize, fill: impl FnOnce(usize, (&mut [Self::Item], &mut [MaybeUninit<Self::Item>])), ) -> MemResult<&mut [Self::Item]>

Low-level growth: extends the memory by cap elements. Read more
Source§

fn shrink(&mut self, cap: usize) -> MemResult<()>

Removes the last cap elements, dropping them.
Source§

fn size_hint(&self) -> Option<usize>

Returns an optional hint about the total capacity, if known.
Source§

unsafe fn grow_assumed( &mut self, cap: usize, ) -> Result<&mut [Self::Item], Error>

grow which assumes that the memory is already initialized Read more
Source§

unsafe fn grow_zeroed(&mut self, cap: usize) -> Result<&mut [Self::Item], Error>

Safety Read more
Source§

unsafe fn grow_zeroed_exact( &mut self, cap: usize, ) -> Result<&mut [Self::Item], Error>

Safety Read more
Source§

fn grow_with( &mut self, addition: usize, f: impl FnMut() -> Self::Item, ) -> Result<&mut [Self::Item], Error>

Grows by addition elements, initializing each with the closure f.
Source§

unsafe fn grow_with_exact( &mut self, addition: usize, f: impl FnMut() -> Self::Item, ) -> Result<&mut [Self::Item], Error>

Safety Read more
Source§

unsafe fn grow_filled_exact( &mut self, cap: usize, value: Self::Item, ) -> Result<&mut [Self::Item], Error>
where Self::Item: Clone,

Safety Read more
Source§

fn grow_within<R>(&mut self, range: R) -> Result<&mut [Self::Item], Error>
where R: RangeBounds<usize>, Self::Item: Clone,

Grows by cloning a sub-range of the currently allocated data.
Source§

fn grow_from_slice( &mut self, src: &[Self::Item], ) -> Result<&mut [Self::Item], Error>
where Self::Item: Clone,

Grows by cloning all elements from src.

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<All> ErasedMem for All
where All: RawMem + ?Sized,

Source§

type Item = <All as RawMem>::Item

The element type.
Source§

fn erased_allocated(&self) -> &[<All as ErasedMem>::Item]

Returns a shared slice of initialized elements (type-erased).
Source§

fn erased_allocated_mut(&mut self) -> &mut [<All as ErasedMem>::Item]

Returns a mutable slice of initialized elements (type-erased).
Source§

unsafe fn erased_grow( &mut self, cap: usize, fill: &mut dyn FillFn<<All as ErasedMem>::Item>, ) -> Result<&mut [<All as ErasedMem>::Item], Error>

Safety Read more
Source§

fn erased_shrink(&mut self, cap: usize) -> Result<(), Error>

Removes the last cap elements (type-erased).
Source§

fn erased_size_hint(&self) -> Option<usize>

Returns an optional capacity hint (type-erased).
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.