Skip to main content

QueryValue

Trait QueryValue 

Source
pub trait QueryValue: Sized {
    // Required method
    fn from_view(view: &ViewValue) -> Result<Self, ZeroValueError>;

    // Provided method
    fn update_from_view(
        &mut self,
        previous: &mut ViewValue,
        view: &ViewValue,
    ) -> Result<(), ZeroValueError> { ... }
}
Expand description

What a query materializes to: its rows (Vec<Row>, Option<Row> after one()), or the value of an aggregate, such as the i64 of count().

Required Methods§

Source

fn from_view(view: &ViewValue) -> Result<Self, ZeroValueError>

Reads the query’s result from its view.

Provided Methods§

Source

fn update_from_view( &mut self, previous: &mut ViewValue, view: &ViewValue, ) -> Result<(), ZeroValueError>

Reads view into self, which was read from previous, as from_view would, keeping what it can of self, and makes previous what was read: a LiveView reads each update so. On an error both are left as they were. By default it reads view anew; rows (Vec<E>) read only the entries that changed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl QueryValue for i64

The value of count().

Source§

impl<E: QueryElement> QueryValue for Vec<E>

Source§

fn update_from_view( &mut self, previous: &mut ViewValue, view: &ViewValue, ) -> Result<(), ZeroValueError>

Keeps the rows whose entries are equal, and reads the others (the Swift client’s RowCache). Most updates change a few rows in place, or insert or remove one, so the entries are matched in order, skipping at most one. previous becomes a copy of the entries changed in the same way, so the view, which then shares its rows with nothing, changes them in place.

Source§

fn from_view(view: &ViewValue) -> Result<Self, ZeroValueError>

Source§

impl<T: OptionalQueryElement> QueryValue for Option<T>

Implementors§