1pub mod auth;
5pub mod databases;
6pub mod endpoint;
7pub mod entry;
8pub mod http_executor;
9pub mod logging;
10pub mod object;
11pub mod project;
12pub mod socket_executor;
13
14#[cfg(not(target_arch = "wasm32"))]
15pub mod runtime;
16
17mod serialize_utils;
18
19pub use serialize_utils::*;
20
21use std::any::Any;
22use std::cell::Cell;
23use std::collections::HashMap;
24use std::convert::Infallible;
25use std::env::current_dir;
26use std::fmt::Debug;
27use std::mem::MaybeUninit;
28use std::net::SocketAddr;
29use std::path::PathBuf;
30use std::pin::Pin;
31use std::sync::Arc;
32
33use boxed_any::*;
34use boxed_any_derive::*;
35use rustyrosetta::{codec::*, *};
36
37use async_trait::*;
38use bytes::Bytes as ConnBytes;
39use color_eyre::Section;
40use compact_str::*;
41use derive_builder::*;
42use derive_more::{Constructor, Display};
43use dyn_clone::*;
44use eyre::{Context, ContextCompat, Result, bail, eyre};
45use futures::future::BoxFuture;
46use getset::*;
47use http::StatusCode;
48use http_body_util::combinators::BoxBody;
49use hyper::Request;
50use hyper_tungstenite::HyperWebsocket;
51use iocraft::prelude::*;
52use serde::{Deserialize, Serialize};
53use serde_with::{IfIsHumanReadable, json::JsonString, serde_as};
54use thiserror::*;
55use tokio::sync::OnceCell;
56use tracing::*;
57
58pub type ResultContext = CompactString; pub type DatabaseId = CompactString;
61pub type DataSchemaDiscoveryMethodId = CompactString;
62pub type ExternalDriverId = CompactString;
63
64pub type ExecutionAtomId = CompactString;
65
66pub type UserId = usize;
67
68pub const BINARY_MAGIC: &'static [u8] = b"waveless_binary";
70
71pub const DATABASE_LIMIT: usize = 9;
73
74pub static DATABASES_CONNS: OnceCell<databases::DatabasesManager> = OnceCell::const_new();
75
76thread_local! {
77 pub static BINARY_MODE: Cell<bool> = const { Cell::new(false) }; }
79
80pub trait AnyExt: Any + BoxedAny + DynClone + Send + Sync + Debug {
81 fn name(&self) -> &str;
82}
83
84#[derive(Error, Debug)]
85pub enum RequestError {
86 #[error("Request error.")]
87 Expected(StatusCode, CompactString),
88 #[error(transparent)]
89 Other(#[from] eyre::Error),
90}
91
92pub fn get_workspace_root(project_file: &str) -> Result<PathBuf> {
94 let mut current_dir = current_dir().unwrap();
95 if current_dir.join(project_file).exists() {
96 return Ok(current_dir);
97 } else {
98 while current_dir.pop() {
99 if current_dir.join(project_file).exists() {
100 return Ok(current_dir);
101 }
102 }
103 };
104 Err(eyre!(
105 "The project's worspace root path cannot be determined."
106 ))
107}