Skip to main content

Budget

Struct Budget 

Source
pub struct Budget {
    pub looked_up: Vec<Vec<String>>,
    pub this_part: usize,
    pub part_limit: usize,
    pub total_limit: usize,
    pub written: Vec<Vec<String>>,
    pub verified: Vec<Vec<String>>,
    pub verifying: bool,
}
Expand description

The lookups a request may still make (tools/oracle/rules_lookups.py): a single read or write may look up 10 distinct documents, a query 20, and a batch 10 per write and 20 in all. A document looked up again costs nothing, across the writes of a batch too, and so does the document a request reads or writes and every document its batch writes (tools/oracle/rules_eval.py).

The verifies of a commit count as its writes (tools/oracle/rules_verify.py). The documents they verify cost nothing through getAfter() and existsAfter() only, and in a verify’s condition so do the documents the batch writes.

Fields§

§looked_up: Vec<Vec<String>>

Distinct documents looked up so far, by the whole request or batch.

§this_part: usize

How many of them the current write or read looked up first.

§part_limit: usize§total_limit: usize§written: Vec<Vec<String>>

The documents the batch writes, from databases (see Budget::add_written).

§verified: Vec<Vec<String>>

The documents the batch verifies, from databases (see Budget::add_verified).

§verifying: bool

Whether a verify is being decided (see Budget::next_verify).

Implementations§

Source§

impl Budget

Source

pub fn add_written(&mut self, path: Vec<String>)

Records a document the batch writes (or deletes): any write of the batch may look it up for free. The document of the request being decided is free without this.

Source

pub fn add_verified(&mut self, path: Vec<String>)

Records a document the batch verifies: any write or verify of the batch may look it up with getAfter() or existsAfter() for free.

Source

pub fn free(&self, path: &[String], after: bool) -> bool

Whether path costs nothing to look up, after the writes or before them, besides the document of the request being decided and those looked up already.

Source

pub fn single() -> Self

A single read or write.

Source

pub fn query() -> Self

A query.

Source

pub fn batch() -> Self

A batch of writes; call Budget::next_write before each one.

Source

pub fn next_write(&mut self)

Source

pub fn next_verify(&mut self)

Like Budget::next_write, before a verify of the batch.

Trait Implementations§

Source§

impl Clone for Budget

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 Budget

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
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> Same for T

Source§

type Output = T

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