Struct gix_fs::SharedFileSnapshotMut

source ·
pub struct SharedFileSnapshotMut<T: Debug>(pub MutableOnDemand<Option<SharedFileSnapshot<T>>>);
Expand description

Use this type for fields in structs that are to store the FileSnapshot, typically behind an OwnShared.

Note that the resource itself is behind another OwnShared to allow it to be used without holding any kind of lock, hence without blocking updates while it is used.

Tuple Fields§

§0: MutableOnDemand<Option<SharedFileSnapshot<T>>>

Implementations§

source§

impl<T: Debug> SharedFileSnapshotMut<T>

source

pub fn new() -> Self

Create a new instance of this type.

Useful in case Default::default() isn’t working for some reason.

source

pub fn force_refresh<E>( &self, open: impl FnOnce() -> Result<Option<(SystemTime, T)>, E> ) -> Result<(), E>

Refresh state forcefully by re-opening the resource. Note that open() returns None if the resource isn’t present on disk, and that it’s critical that the modified time is obtained before opening the resource.

source

pub fn recent_snapshot<E>( &self, current_modification_time: impl FnMut() -> Option<SystemTime>, open: impl FnOnce() -> Result<Option<T>, E> ) -> Result<Option<SharedFileSnapshot<T>>, E>

Assure that the resource in state is up-to-date by comparing the current_modification_time with the one we know in state and by acting accordingly. Returns the potentially updated/reloaded resource if it is still present on disk, which then represents a snapshot that is up-to-date in that very moment, or None if the underlying file doesn’t exist.

Note that even though this is racy, each time a request is made there is a chance to see the actual state.

Trait Implementations§

source§

impl<T: Debug + Debug> Debug for SharedFileSnapshotMut<T>

source§

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

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

impl<T: Default + Debug> Default for SharedFileSnapshotMut<T>

source§

fn default() -> SharedFileSnapshotMut<T>

Returns the “default value” for a type. Read more
source§

impl<T: Debug> Deref for SharedFileSnapshotMut<T>

§

type Target = RefCell<Option<Rc<FileSnapshot<T>>>>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

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> 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>,

§

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>,

§

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.