Skip to main content

FileBudget

Struct FileBudget 

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

The installation’s places for open files, shared by every store its app opens. Cloning shares them. The app makes one when it starts, and each piece of work takes a lease of places from it (E1).

Implementations§

Source§

impl FileBudget

Source

pub fn new(size: NonZeroUsize) -> Self

A budget of size places, at most u32::MAX. The app makes one with under_descriptor_limit; a test that needs a size makes it here.

Source

pub fn under_descriptor_limit() -> Self

A budget of an eighth of the process’s descriptor limit, at least 1: 32 places under a macOS app’s limit of 256, 128 under 1024. A process with no limit counts as 10240, macOS’s OPEN_MAX, and so does Windows, where the handles std::fs and SQLite open have no limit.

One place stands for at most 4 descriptors: the file it opens, or the cache files a stream’s reads in flight open (at most 3), and one file the work writes beside it. The places therefore take at most half the limit, and the other half holds what the budget doesn’t count: each open store’s database files, locks, sockets and the platform’s own descriptors. The limit is read once, here.

Source

pub fn size(&self) -> usize

How many places the budget has.

Source

pub async fn lease(&self, count: usize) -> Result<FileLease, LeaseTooLarge>

Take count places in one wait, behind every lease that began waiting before. Call it only while holding no place of this budget: a holder that waits here can wait forever. A count above the budget’s size fails at once.

Source

pub fn lease_blocking(&self, count: usize) -> Result<FileLease, LeaseTooLarge>

Self::lease, blocking this thread in the same line as the async leases. Call it only off the async workers: on the blocking pool or a thread of the caller’s own.

Source

pub fn watch(&self) -> FileBudgetWatch

What a test reads of this budget’s use.

Source§

impl FileBudget

Source

pub fn for_test() -> Self

A budget of 64 places, as an installation made for a test has, with no other budget’s work competing for them.

Trait Implementations§

Source§

impl Clone for FileBudget

Source§

fn clone(&self) -> Self

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 Debug for FileBudget

Source§

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

Formats the value using the given formatter. Read more

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
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more