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#![warn(
14    clippy::all,
15    clippy::panic_in_result_fn,
16    clippy::await_holding_refcell_ref
17)]
18
19mod client;
20mod session;
21mod table;
22mod table_data;
23mod view;
24
25pub mod config;
26
27#[allow(unknown_lints)]
28#[allow(clippy::all)]
29mod proto;
30pub mod utils;
31
32pub use crate::client::{Client, ClientHandler, Features, ReconnectCallback, SystemInfo};
33pub use crate::proto::{ColumnType, SortOp, ViewOnUpdateResp};
34pub use crate::session::{ProxySession, Session};
35pub use crate::table::{
36    DeleteOptions, Schema, Table, TableInitOptions, TableReadFormat, UpdateOptions,
37    ValidateExpressionsData,
38};
39pub use crate::table_data::{TableData, UpdateData};
40pub use crate::view::{OnUpdateMode, OnUpdateOptions, View, ViewWindow};
41
42pub type ClientError = utils::ClientError;
43pub type ExprValidationError = crate::proto::table_validate_expr_resp::ExprValidationError;
44
45#[doc(hidden)]
46pub mod vendor {
47    pub use paste;
48}
49
50/// Assert that an implementation of domain language wrapper for [`Table`]
51/// implements the expected API. As domain languages have different API needs,
52/// a trait isn't useful for asserting that the entire API is implemented,
53/// because the signatures will not match exactly (unless every method is
54/// made heavily generic). Instead, this macro complains when a method name
55/// is missing.
56#[doc(hidden)]
57#[macro_export]
58macro_rules! assert_table_api {
59    ($x:ty) => {
60        $crate::vendor::paste::paste! {
61            #[cfg(debug_assertions)]
62            fn [< _assert_table_api_ $x:lower >]() {
63                let _ = (
64                    &$x::clear,
65                    &$x::columns,
66                    &$x::delete,
67                    &$x::get_index,
68                    &$x::get_limit,
69                    &$x::get_client,
70                    &$x::make_port,
71                    &$x::on_delete,
72                    &$x::remove_delete,
73                    &$x::replace,
74                    &$x::schema,
75                    &$x::size,
76                    &$x::update,
77                    &$x::validate_expressions,
78                    &$x::view,
79                );
80            }
81        }
82    };
83}
84
85/// Similar to [`assert_table_api`], but for [`View`]. See [`assert_table_api`].
86#[doc(hidden)]
87#[macro_export]
88macro_rules! assert_view_api {
89    ($x:ty) => {
90        $crate::vendor::paste::paste! {
91            #[cfg(debug_assertions)]
92            fn [< _assert_table_api_ $x:lower >]() {
93                let _ = (
94                    &$x::column_paths,
95                    &$x::delete,
96                    &$x::dimensions,
97                    &$x::expression_schema,
98                    &$x::get_config,
99                    &$x::get_min_max,
100                    &$x::num_rows,
101                  //  &$x::on_update,
102                    &$x::remove_update,
103                    &$x::on_delete,
104                    &$x::remove_delete,
105                    &$x::schema,
106                    &$x::to_arrow,
107                    &$x::to_columns_string,
108                    &$x::to_json_string,
109                    &$x::to_csv,
110                );
111            }
112        }
113    };
114}