perspective_client/lib.rs
1// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7// ┃ Copyright (c) 2017, the Perspective Authors. ┃
8// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9// ┃ This file is part of the Perspective library, distributed under the terms ┃
10// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
13//! `perspective_client` is the client implementation of
14//! [Perspective](https://perspective.finos.org), designed to be used from Rust
15//! directly, and as a core to `perspective-js` and `perspective-python` crates
16//! which wrap language-specific bindings for this module.
17//!
18//! # See also
19//!
20//! - [`perspective-rs`](https://docs.rs/perspective/latest/) for the Rust
21//! Client and Server APIs.
22//! - [`perspective-js`](https://docs.rs/perspective-js/latest/) for the
23//! JavaScript API.
24//! - [`perspective-python`](https://docs.rs/perspective-python/latest/) for the
25//! Python API.
26//! - [`perspective-server`](https://docs.rs/perspective-server/latest/) for
27//! Data Binding details.
28//! - [`perspective-viewer`](https://docs.rs/perspective-viewer/latest/) for the
29//! WebAssembly `<perspective-viewer>` Custom Element API.
30
31#![warn(
32 clippy::all,
33 clippy::panic_in_result_fn,
34 clippy::await_holding_refcell_ref
35)]
36
37mod client;
38mod session;
39mod table;
40mod table_data;
41mod view;
42
43pub mod config;
44
45#[allow(clippy::all)]
46mod proto;
47
48pub mod utils;
49
50pub use crate::client::{Client, ClientHandler, Features, ReconnectCallback, SystemInfo};
51pub use crate::session::{ProxySession, Session};
52pub use crate::table::{
53 DeleteOptions, ExprValidationResult, Table, TableInitOptions, TableReadFormat, UpdateOptions,
54};
55pub use crate::table_data::{TableData, UpdateData};
56pub use crate::view::{
57 ColumnWindow, OnUpdateData, OnUpdateMode, OnUpdateOptions, View, ViewWindow,
58};
59
60pub type ClientError = utils::ClientError;
61pub type ExprValidationError = crate::proto::table_validate_expr_resp::ExprValidationError;
62
63#[doc(hidden)]
64pub mod vendor {
65 pub use paste;
66}
67
68/// Assert that an implementation of domain language wrapper for [`Table`]
69/// implements the expected API. As domain languages have different API needs,
70/// a trait isn't useful for asserting that the entire API is implemented,
71/// because the signatures will not match exactly (unless every method is
72/// made heavily generic). Instead, this macro complains when a method name
73/// is missing.
74#[doc(hidden)]
75#[macro_export]
76macro_rules! assert_table_api {
77 ($x:ty) => {
78 $crate::vendor::paste::paste! {
79 #[cfg(debug_assertions)]
80 fn [< _assert_table_api_ $x:lower >]() {
81 let _ = (
82 &$x::clear,
83 &$x::columns,
84 &$x::delete,
85 &$x::get_index,
86 &$x::get_limit,
87 &$x::get_client,
88 &$x::make_port,
89 &$x::on_delete,
90 &$x::remove_delete,
91 &$x::replace,
92 &$x::schema,
93 &$x::size,
94 &$x::update,
95 &$x::validate_expressions,
96 &$x::view,
97 );
98 }
99 }
100 };
101}
102
103/// Similar to [`assert_table_api`], but for [`View`]. See [`assert_table_api`].
104#[doc(hidden)]
105#[macro_export]
106macro_rules! assert_view_api {
107 ($x:ty) => {
108 $crate::vendor::paste::paste! {
109 #[cfg(debug_assertions)]
110 fn [< _assert_table_api_ $x:lower >]() {
111 let _ = (
112 &$x::column_paths,
113 &$x::delete,
114 &$x::dimensions,
115 &$x::expression_schema,
116 &$x::get_config,
117 &$x::get_min_max,
118 &$x::num_rows,
119 // &$x::on_update,
120 &$x::remove_update,
121 &$x::on_delete,
122 &$x::remove_delete,
123 &$x::schema,
124 &$x::to_arrow,
125 &$x::to_columns_string,
126 &$x::to_json_string,
127 &$x::to_csv,
128 );
129 }
130 }
131 };
132}