Struct perspective_client::View

source ·
pub struct View {
    pub name: String,
    /* private fields */
}

Fields§

§name: String

Implementations§

source§

impl View

source

pub fn new(name: String, client: Client) -> Self

source

pub async fn column_paths(&self) -> ClientResult<Vec<String>>

Returns an array of strings containing the column paths of the View without any of the source columns.

A column path shows the columns that a given cell belongs to after pivots are applied.

source

pub async fn dimensions(&self) -> ClientResult<ViewDimensionsResp>

Returns this View’s dimensions, row and column count, as well as those of the crate::Table from which it was derived.

  • num_table_rows - The number of rows in the underlying crate::Table.
  • num_table_columns - The number of columns in the underlying crate::Table (including the index column if this crate::Table was constructed with one).
  • num_view_rows - The number of rows in this View. If this View has a group_by clause, num_view_rows will also include aggregated rows.
  • num_view_columns - The number of columns in this View. If this View has a split_by clause, num_view_columns will include all column paths, e.g. the number of columns clause times the number of split_by groups.
source

pub async fn expression_schema( &self, ) -> ClientResult<HashMap<String, ColumnType>>

The expression schema of this view, which contains only the expressions created on this view.

A schema is an Object, the keys of which are the columns of this view, and the values are their string type names. If this view is aggregated, these will be the aggregated types; otherwise these types will be the same as the columns in the underlying table.

source

pub async fn get_config(&self) -> ClientResult<ViewConfig>

A copy of the config object passed to the [perspective_client::Table::view] method which created this [perspective_client::View].

source

pub async fn num_rows(&self) -> ClientResult<u32>

The number of aggregated rows in this view. This is affected by the “group_by” configuration parameter supplied to this view’s contructor.

§Returns

The number of aggregated rows.

source

pub async fn schema(&self) -> ClientResult<HashMap<String, ColumnType>>

The schema of this view.

A schema is an Object, the keys of which are the columns of this view, and the values are their string type names. If this view is aggregated, theses will be the aggregated types; otherwise these types will be the same as the columns in the underlying table.

§Examples
// Create a view
const view = await table.view({
    columns: ["a", "b"],
});
const schema = await view.schema(); // {a: "float", b: "string"}
source

pub async fn to_arrow(&self, window: ViewWindow) -> ClientResult<Bytes>

Serializes a view to the Apache Arrow data format.

source

pub async fn to_columns_string( &self, window: ViewWindow, ) -> ClientResult<String>

Serializes this view to a string of JSON data. Useful if you want to save additional round trip serialize/deserialize cycles.

source

pub async fn to_json_string(&self, window: ViewWindow) -> ClientResult<String>

Render this View as a JSON string.

source

pub async fn to_csv(&self, window: ViewWindow) -> ClientResult<String>

Serializes this view to CSV data in a standard format.

source

pub async fn delete(&self) -> ClientResult<()>

Delete this View and clean up all resources associated with it. View objects do not stop consuming resources or processing updates when they are garbage collected - you must call this method to reclaim these.

source

pub async fn get_min_max( &self, column_name: String, ) -> ClientResult<(String, String)>

Calculates the [min, max] of the leaf nodes of a column column_name.

§Returns

A tuple of [min, max], whose types are column and aggregate dependent.

source

pub async fn on_update<T, U>( &self, on_update: T, options: OnUpdateOptions, ) -> ClientResult<u32>
where T: Fn(ViewOnUpdateResp) -> U + Send + Sync + 'static, U: Future<Output = ()> + Send + 'static,

This is used when constructing a super::table::Table from a View. The callback needs to be async to wire up the views on_update to the tables.

source

pub async fn remove_update(&self, update_id: u32) -> ClientResult<()>

Unregister a previously registered update callback with this view.

§Example
// remove an `on_update` callback
const callback = () => console.log("Updated!");
view.remove_update(callback);
source

pub async fn on_delete( &self, on_delete: Box<dyn Fn() + Send + Sync + 'static>, ) -> ClientResult<u32>

Register a callback with this view. Whenever the view is deleted, this callback will be invoked.

§Example
// attach an `on_delete` callback
view.on_delete(() => console.log("Deleted!"));
source

pub async fn remove_delete(&self, callback_id: u32) -> ClientResult<()>

Unregister a previously registered delete callback with this view.

§Example
// remove an `on_delete` callback
const callback = () => console.log("Deleted!");
view.remove_delete(callback);
source

pub async fn collapse(&self, row_index: u32) -> ClientResult<u32>

Collapses the row at index row_index.

This is used during a pivot.

§Examples
// make table
// make view with pivot
// collapse a row.
source

pub async fn expand(&self, row_index: u32) -> ClientResult<u32>

Expands the row at index row_index.

This is used during a pivot.

§Examples
// make table
// make view with pivot
// expand a row.
source

pub async fn set_depth(&self, depth: u32) -> ClientResult<()>

Set expansion depth of the pivot tree.

Trait Implementations§

source§

impl Clone for View

source§

fn clone(&self) -> View

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for View

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for View

§

impl !RefUnwindSafe for View

§

impl Send for View

§

impl Sync for View

§

impl Unpin for View

§

impl !UnwindSafe for View

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

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

§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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