QuotaManager

Struct QuotaManager 

Source
pub struct QuotaManager { /* private fields */ }
Expand description

Evicts least-recently-used files in a managed directory when asked to do so.

QuotaManager does not observe file system mutations! You have to tell it about any files you create or delete in this directory. It stores this information in a sqlite database file at a path of your choosing.

Implementations§

Source§

impl QuotaManager

Source

pub fn new(root_path: &Path, db_path: &Path) -> Result<Self, String>

Create an instance for the managed directory given by root_path.

Uses the database at db_path to store information about the files under this directory, and creates it if it doesn’t exist yet, prepopulating it with information about the current files in the managed directory.

Both root_path and the parent directory of db_path must already exist.

Source

pub fn notifier(&self) -> QuotaManagerNotifier

Returns a new QuotaManagerNotifier. This is how you tell this QuotaManager about file creations / accesses

Source

pub async fn finish(self)

Stops the background task that does the evictions, and waits for any currently-running eviction to finish.

Source

pub fn set_max_total_size(&self, max_size_bytes: Option<u64>)

Change the desired maximum total size of the managed directory, in bytes.

Respected during the next eviction.

Source

pub fn set_max_age(&self, max_age_seconds: Option<u64>)

Change the desired maximum age of tracked files in the managed directory, in seconds.

Respected during the next eviction.

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

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.