veilid/veilid-core/src/lib.rs

109 lines
3.4 KiB
Rust
Raw Normal View History

2023-09-01 21:13:05 -04:00
//! # The Veilid Framework
2023-08-29 16:15:47 -04:00
//!
2023-09-01 21:18:45 -04:00
//! Core library used to create a Veilid node and operate it as part of an application.
2023-08-29 16:15:47 -04:00
//!
//! `veilid-core` contains all of the core logic for Veilid and can be used in mobile applications as well as desktop
//! and in-browser WebAssembly apps.
//!
//! The public API is accessed by getting a [VeilidAPI] object via a call to [api_startup], [api_startup_json], or
//! [api_startup_config].
2023-08-29 16:15:47 -04:00
//!
//! From there, a [RoutingContext] object can get you access to public and private routed operations.
//!
2023-09-01 21:13:05 -04:00
//! ## Features
//!
//! The default `veilid-core` configurations are:
//!
//! * `default` - Uses `tokio` as the async runtime.
2023-09-01 21:13:05 -04:00
//!
//! If you use `--no-default-features`, you can switch to other runtimes:
//!
//! * `default-async-std` - Uses `async-std` as the async runtime.
//! * `default-wasm` - When building for the `wasm32` architecture, use this to enable `wasm-bindgen-futures` as the async runtime.
2023-09-01 21:13:05 -04:00
//!
2021-12-07 22:09:45 -05:00
#![deny(clippy::all)]
2023-09-17 19:37:02 -04:00
#![allow(clippy::comparison_chain, clippy::upper_case_acronyms)]
2021-12-09 16:11:52 -05:00
#![deny(unused_must_use)]
2022-11-30 09:39:12 -05:00
#![recursion_limit = "256"]
2022-06-27 23:46:29 -04:00
cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {
#[cfg(any(feature = "rt-async-std", feature = "rt-tokio"))]
compile_error!("features \"rt-async-std\" and \"rt-tokio\" can not be specified for WASM");
} else {
#[cfg(all(feature = "rt-async-std", feature = "rt-tokio"))]
compile_error!(
"feature \"rt-async-std\" and feature \"rt-tokio\" cannot be enabled at the same time"
);
#[cfg(not(any(feature = "rt-async-std", feature = "rt-tokio")))]
compile_error!("exactly one of feature \"rt-async-std\" or feature \"rt-tokio\" must be specified");
}
}
2021-11-22 11:28:30 -05:00
#[macro_use]
extern crate alloc;
mod attachment_manager;
2022-02-06 21:18:42 -05:00
mod core_context;
2022-10-30 19:29:31 -04:00
mod crypto;
2021-11-22 11:28:30 -05:00
mod intf;
2024-03-07 16:49:59 -05:00
mod logging;
2021-11-22 11:28:30 -05:00
mod network_manager;
mod routing_table;
mod rpc_processor;
2023-05-29 15:24:57 -04:00
mod storage_manager;
mod table_store;
2021-11-22 11:28:30 -05:00
mod veilid_api;
mod veilid_config;
2023-08-31 22:01:00 -04:00
mod wasm_helpers;
2021-11-22 11:28:30 -05:00
2024-02-14 21:33:04 -05:00
pub use self::core_context::{api_startup, api_startup_config, api_startup_json, UpdateCallback};
pub use self::logging::{
ApiTracingLayer, VeilidLayerFilter, DEFAULT_LOG_FACILITIES_ENABLED_LIST,
2024-07-03 21:00:12 -04:00
DEFAULT_LOG_FACILITIES_IGNORE_LIST, DURATION_LOG_FACILITIES, FLAME_LOG_FACILITIES_IGNORE_LIST,
};
2021-11-22 11:28:30 -05:00
pub use self::veilid_api::*;
pub use self::veilid_config::*;
2022-11-26 21:37:23 -05:00
pub use veilid_tools as tools;
2021-11-22 11:28:30 -05:00
/// The on-the-wire serialization format for Veilid RPC.
2021-11-22 11:28:30 -05:00
pub mod veilid_capnp {
2023-11-07 14:19:28 -05:00
include!("../proto/veilid_capnp.rs");
2021-11-22 11:28:30 -05:00
}
2023-08-29 16:15:47 -04:00
#[doc(hidden)]
2021-11-22 11:28:30 -05:00
pub mod tests;
2022-01-27 22:02:16 -05:00
/// Return the cargo package version of veilid-core in string format.
2022-01-27 22:02:16 -05:00
pub fn veilid_version_string() -> String {
env!("CARGO_PKG_VERSION").to_owned()
}
2023-08-29 16:15:47 -04:00
/// Return the cargo package version of veilid-core in tuple format.
2022-01-27 22:02:16 -05:00
pub fn veilid_version() -> (u32, u32, u32) {
(
u32::from_str(env!("CARGO_PKG_VERSION_MAJOR")).unwrap(),
u32::from_str(env!("CARGO_PKG_VERSION_MINOR")).unwrap(),
u32::from_str(env!("CARGO_PKG_VERSION_PATCH")).unwrap(),
)
}
2022-01-31 22:47:17 -05:00
2022-03-03 20:45:39 -05:00
#[cfg(target_os = "android")]
2022-12-01 14:32:02 -05:00
pub use intf::android::veilid_core_setup_android;
2022-03-03 20:45:39 -05:00
2023-06-08 14:07:09 -04:00
use cfg_if::*;
use enumset::*;
use eyre::{bail, eyre, Report as EyreReport, Result as EyreResult, WrapErr};
2023-08-29 16:15:47 -04:00
#[allow(unused_imports)]
2023-08-24 16:15:51 -04:00
use futures_util::stream::{FuturesOrdered, FuturesUnordered};
2024-10-10 20:16:39 -04:00
use indent::*;
2023-07-15 16:18:13 -04:00
use parking_lot::*;
2023-06-08 14:07:09 -04:00
use schemars::{schema_for, JsonSchema};
use serde::*;
use stop_token::*;
use thiserror::Error as ThisError;
2023-07-15 16:18:13 -04:00
use tracing::*;
use veilid_tools::*;
2023-08-31 22:01:00 -04:00
use wasm_helpers::*;