Skip to main content

QuotaCharge

Struct QuotaCharge 

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

One write’s claim on a DiskQuota, from its first byte until it commits or is abandoned.

A write that replaces a file within one host call, where no program code can touch that file before it commits, may draw on the file’s size first and reserve only the growth beyond it: its allowance. Only a file no handle holds gives an allowance, since a held file’s bytes stay on disk after its name goes. A write the program can interleave with replaces nothing up front, so every byte it writes counts until it commits, and re-reads what it replaces with cover just before committing. commit then frees the replaced file. A write that truncates and rewrites a file itself (in_place) draws on the old contents even while readers hold the file, since they are gone either way; a writer’s own file is left for the writer to settle. Dropping an uncommitted charge gives back everything it reserved, for a write whose output is gone.

Implementations§

Source§

impl QuotaCharge

Source

pub fn new( quota: Option<Arc<DiskQuota>>, replaced: Option<(FileIdentity, u64)>, ) -> Self

A charge that may draw on replaced, the regular file the write replaces.

Source

pub fn in_place( quota: Option<Arc<DiskQuota>>, rewritten: Option<(FileIdentity, u64)>, ) -> Self

A charge for rewriting rewritten, a regular file and its size, in place: the same file takes the new contents, so the old ones are freed at once even while readers hold it. A writer’s own file is the writer’s to settle, so rewriting it frees nothing and every new byte counts.

Source

pub fn reserve(&mut self, bytes: u64) -> Result<(), QuotaExceeded>

Claim bytes about to be written: from the allowance first, the rest from the quota.

Source

pub fn unreserve(&mut self, bytes: u64)

Give back bytes claimed by the last reserve that were never written, as after a short write.

Source

pub fn cover( &mut self, replaced: Option<(FileIdentity, u64)>, ) -> Result<(), QuotaExceeded>

Settle against the file the write is about to replace, as it stands now: whatever the write drew from its allowance beyond that file’s size must be reserved after all, or the write refused.

Source

pub fn commit(self)

The write landed: free what it replaced beyond the allowance it drew on. A replaced file goes once no handle holds it; old contents rewritten in place go at once.

Source

pub fn settle_at(self, left: u64)

The write failed partway, leaving its file at left bytes: count the file at that size. A file rewritten in place had its old contents counted too; otherwise no more than was reserved can be the write’s own.

Source

pub fn keep(self)

The write failed but its bytes may still be on disk, under a name the program gave them: keep them counted rather than giving them back.

Source

pub fn release_when_closed(self, written: FileIdentity)

The write failed and its file, written, has no name left: its bytes go once every handle on it closes.

Trait Implementations§

Source§

impl Debug for QuotaCharge

Source§

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

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

impl Drop for QuotaCharge

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

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

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

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