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::{OnUpdateData, OnUpdateMode, OnUpdateOptions, View, ViewWindow};
57
58pub type ClientError = utils::ClientError;
59pub type ExprValidationError = crate::proto::table_validate_expr_resp::ExprValidationError;
60
61#[doc(hidden)]
62pub mod vendor {
63 pub use paste;
64}
65
66/// Assert that an implementation of domain language wrapper for [`Table`]
67/// implements the expected API. As domain languages have different API needs,
68/// a trait isn't useful for asserting that the entire API is implemented,
69/// because the signatures will not match exactly (unless every method is
70/// made heavily generic). Instead, this macro complains when a method name
71/// is missing.
72#[doc(hidden)]
73#[macro_export]
74macro_rules! assert_table_api {
75 ($x:ty) => {
76 $crate::vendor::paste::paste! {
77 #[cfg(debug_assertions)]
78 fn [< _assert_table_api_ $x:lower >]() {
79 let _ = (
80 &$x::clear,
81 &$x::columns,
82 &$x::delete,
83 &$x::get_index,
84 &$x::get_limit,
85 &$x::get_client,
86 &$x::make_port,
87 &$x::on_delete,
88 &$x::remove_delete,
89 &$x::replace,
90 &$x::schema,
91 &$x::size,
92 &$x::update,
93 &$x::validate_expressions,
94 &$x::view,
95 );
96 }
97 }
98 };
99}
100
101/// Similar to [`assert_table_api`], but for [`View`]. See [`assert_table_api`].
102#[doc(hidden)]
103#[macro_export]
104macro_rules! assert_view_api {
105 ($x:ty) => {
106 $crate::vendor::paste::paste! {
107 #[cfg(debug_assertions)]
108 fn [< _assert_table_api_ $x:lower >]() {
109 let _ = (
110 &$x::column_paths,
111 &$x::delete,
112 &$x::dimensions,
113 &$x::expression_schema,
114 &$x::get_config,
115 &$x::get_min_max,
116 &$x::num_rows,
117 // &$x::on_update,
118 &$x::remove_update,
119 &$x::on_delete,
120 &$x::remove_delete,
121 &$x::schema,
122 &$x::to_arrow,
123 &$x::to_columns_string,
124 &$x::to_json_string,
125 &$x::to_csv,
126 );
127 }
128 }
129 };
130}