veilid/veilid-tools/src/lib.rs

144 lines
3.9 KiB
Rust
Raw Normal View History

2021-11-22 16:28:30 +00:00
// mod bump_port;
2023-06-23 16:05:28 +00:00
mod assembly_buffer;
2022-01-05 17:01:02 +00:00
mod async_peek_stream;
2022-10-02 22:47:36 +00:00
mod async_tag_lock;
2022-11-30 00:22:33 +00:00
mod callback_state_machine;
2022-01-05 17:01:02 +00:00
mod clone_stream;
2021-11-22 16:28:30 +00:00
mod eventual;
mod eventual_base;
mod eventual_value;
mod eventual_value_clone;
2022-11-27 02:37:23 +00:00
mod interval;
2021-11-22 16:28:30 +00:00
mod ip_addr_port;
mod ip_extra;
2021-12-17 02:57:28 +00:00
mod log_thru;
2022-06-13 00:58:02 +00:00
mod must_join_handle;
mod must_join_single_future;
2022-06-05 00:18:26 +00:00
mod mutable_future;
2022-07-14 20:57:34 +00:00
mod network_result;
2022-11-27 02:37:23 +00:00
mod random;
2021-11-22 16:28:30 +00:00
mod single_shot_eventual;
2022-11-27 02:37:23 +00:00
mod sleep;
mod spawn;
mod split_url;
2021-11-22 16:28:30 +00:00
mod tick_task;
2022-11-27 02:37:23 +00:00
mod timeout;
2022-07-10 21:36:50 +00:00
mod timeout_or;
2022-11-27 02:37:23 +00:00
mod timestamp;
2021-11-22 16:28:30 +00:00
mod tools;
2022-11-27 02:37:23 +00:00
#[cfg(target_arch = "wasm32")]
mod wasm;
2021-11-22 16:28:30 +00:00
pub type PinBox<T> = Pin<Box<T>>;
pub type PinBoxFuture<T> = PinBox<dyn Future<Output = T> + 'static>;
pub type PinBoxFutureLifetime<'a, T> = PinBox<dyn Future<Output = T> + 'a>;
pub type SendPinBoxFuture<T> = PinBox<dyn Future<Output = T> + Send + 'static>;
pub type SendPinBoxFutureLifetime<'a, T> = PinBox<dyn Future<Output = T> + Send + 'a>;
2022-11-06 21:07:56 +00:00
pub use std::borrow::{Cow, ToOwned};
pub use std::boxed::Box;
pub use std::cell::RefCell;
pub use std::cmp;
pub use std::collections::btree_map::BTreeMap;
pub use std::collections::btree_set::BTreeSet;
pub use std::collections::hash_map::HashMap;
pub use std::collections::hash_set::HashSet;
pub use std::collections::LinkedList;
pub use std::collections::VecDeque;
pub use std::convert::{TryFrom, TryInto};
pub use std::fmt;
pub use std::future::Future;
pub use std::mem;
2022-11-26 19:16:02 +00:00
pub use std::net::{
IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs,
};
2022-11-06 21:07:56 +00:00
pub use std::ops::{Fn, FnMut, FnOnce};
pub use std::pin::Pin;
pub use std::rc::Rc;
2022-11-27 14:00:20 +00:00
pub use std::str::FromStr;
2022-11-27 03:18:55 +00:00
pub use std::string::{String, ToString};
2022-11-06 21:07:56 +00:00
pub use std::sync::atomic::{AtomicBool, Ordering};
pub use std::sync::{Arc, Weak};
pub use std::task;
pub use std::time::Duration;
pub use std::vec::Vec;
2021-11-22 16:28:30 +00:00
cfg_if! {
if #[cfg(target_arch = "wasm32")] {
2022-01-04 04:58:26 +00:00
pub use async_lock::Mutex as AsyncMutex;
pub use async_lock::MutexGuard as AsyncMutexGuard;
2022-10-02 22:47:36 +00:00
pub use async_lock::MutexGuardArc as AsyncMutexGuardArc;
2022-06-28 03:46:29 +00:00
pub use async_executors::JoinHandle as LowLevelJoinHandle;
2021-11-22 16:28:30 +00:00
} else {
2022-06-28 03:46:29 +00:00
cfg_if! {
if #[cfg(feature="rt-async-std")] {
pub use async_std::sync::Mutex as AsyncMutex;
pub use async_std::sync::MutexGuard as AsyncMutexGuard;
2022-10-02 22:47:36 +00:00
pub use async_std::sync::MutexGuardArc as AsyncMutexGuardArc;
2022-06-28 03:46:29 +00:00
pub use async_std::task::JoinHandle as LowLevelJoinHandle;
} else if #[cfg(feature="rt-tokio")] {
pub use tokio::sync::Mutex as AsyncMutex;
pub use tokio::sync::MutexGuard as AsyncMutexGuard;
2022-10-02 22:47:36 +00:00
pub use tokio::sync::OwnedMutexGuard as AsyncMutexGuardArc;
2022-06-28 03:46:29 +00:00
pub use tokio::task::JoinHandle as LowLevelJoinHandle;
2022-08-22 17:27:26 +00:00
} else {
#[compile_error("must use an executor")]
2022-06-28 03:46:29 +00:00
}
}
2021-11-22 16:28:30 +00:00
}
}
// pub use bump_port::*;
2023-06-23 16:05:28 +00:00
pub use assembly_buffer::*;
2022-01-05 17:01:02 +00:00
pub use async_peek_stream::*;
2022-10-02 22:47:36 +00:00
pub use async_tag_lock::*;
2022-11-30 00:22:33 +00:00
pub use callback_state_machine::*;
2022-01-05 17:01:02 +00:00
pub use clone_stream::*;
2021-11-22 16:28:30 +00:00
pub use eventual::*;
pub use eventual_base::{EventualCommon, EventualResolvedFuture};
pub use eventual_value::*;
pub use eventual_value_clone::*;
2022-11-27 02:37:23 +00:00
pub use interval::*;
2021-11-22 16:28:30 +00:00
pub use ip_addr_port::*;
pub use ip_extra::*;
2023-06-08 18:07:09 +00:00
pub use log_thru::*;
2022-06-13 00:58:02 +00:00
pub use must_join_handle::*;
pub use must_join_single_future::*;
2022-06-05 00:18:26 +00:00
pub use mutable_future::*;
2022-07-14 20:57:34 +00:00
pub use network_result::*;
2022-11-27 02:37:23 +00:00
pub use random::*;
2021-11-22 16:28:30 +00:00
pub use single_shot_eventual::*;
2022-11-27 02:37:23 +00:00
pub use sleep::*;
pub use spawn::*;
2023-06-08 18:07:09 +00:00
pub use split_url::*;
2021-11-22 16:28:30 +00:00
pub use tick_task::*;
2022-11-27 02:37:23 +00:00
pub use timeout::*;
2022-07-10 21:36:50 +00:00
pub use timeout_or::*;
2022-11-27 02:37:23 +00:00
pub use timestamp::*;
2021-11-22 16:28:30 +00:00
pub use tools::*;
2023-06-08 18:07:09 +00:00
2022-11-27 02:37:23 +00:00
#[cfg(target_arch = "wasm32")]
pub use wasm::*;
2022-11-27 14:00:20 +00:00
// Tests must be public for wasm-pack tests
pub mod tests;
2022-11-28 03:33:41 +00:00
2023-06-08 18:07:09 +00:00
cfg_if! {
if #[cfg(feature = "tracing")] {
use tracing::*;
} else {
use log::*;
}
}
use cfg_if::*;
use futures_util::{AsyncRead, AsyncWrite};
use parking_lot::*;
use stop_token::*;
use thiserror::Error as ThisError;
2023-06-21 17:40:12 +00:00
pub use fn_name;
2022-11-28 03:33:41 +00:00
// For iOS tests
#[no_mangle]
2023-06-08 01:55:23 +00:00
pub extern "C" fn main_rs() {}