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