chiark / gitweb /
make route_packet infallible
[hippotat.git] / src / prelude.rs
1 // Copyright 2021 Ian Jackson and contributors to Hippotat
2 // SPDX-License-Identifier: GPL-3.0-or-later
3 // There is NO WARRANTY.
4
5 pub use std::array;
6 pub use std::collections::{BTreeSet, HashMap, VecDeque};
7 pub use std::convert::{Infallible, TryFrom, TryInto};
8 pub use std::borrow::Cow;
9 pub use std::cell::{RefCell, RefMut};
10 pub use std::cmp::{min, max};
11 pub use std::env;
12 pub use std::fs;
13 pub use std::fmt::{self, Debug, Display, Write as _};
14 pub use std::future::Future;
15 pub use std::io::{self, Cursor, ErrorKind, Read as _, Write as _};
16 pub use std::iter;
17 pub use std::mem;
18 pub use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
19 pub use std::path::{Path, PathBuf};
20 pub use std::panic;
21 pub use std::process;
22 pub use std::pin::Pin;
23 pub use std::str::{self, FromStr};
24 pub use std::sync::Arc;
25 pub use std::task::Poll;
26 pub use std::time::{SystemTime, UNIX_EPOCH};
27
28 pub use cervine::Cow as Cervine;
29 pub use extend::ext;
30 pub use fehler::{throw, throws};
31 pub use futures::{poll, future, FutureExt, StreamExt, TryStreamExt};
32 pub use hyper::body::{Bytes, Buf as _};
33 pub use hyper::{Method, Uri};
34 pub use hyper_tls::HttpsConnector;
35 pub use ipnet::IpNet;
36 pub use itertools::{iproduct, izip, Itertools};
37 pub use lazy_regex::{regex_captures, regex_is_match, regex_replace_all};
38 pub use lazy_static::lazy_static;
39 pub use log::{trace, debug, info, warn, error};
40 pub use memchr::memmem;
41 pub use structopt::StructOpt;
42 pub use subtle::ConstantTimeEq;
43 pub use thiserror::Error;
44 pub use tokio::io::{AsyncBufReadExt, AsyncWriteExt};
45 pub use tokio::pin;
46 pub use tokio::select;
47 pub use tokio::sync::{mpsc, oneshot};
48 pub use tokio::task::{self, JoinHandle};
49 pub use tokio::time::{Duration, Instant};
50 pub use void::{self, Void, ResultVoidExt, ResultVoidErrExt};
51
52 pub use eyre as anyhow;
53 pub use eyre::eyre as anyhow;
54 pub use eyre::WrapErr;
55 pub use eyre::Error as AE;
56
57 pub use crate::config::{self, InstanceConfig, u32Ext as _};
58 pub use crate::ini;
59 pub use crate::ipif::Ipif;
60 pub use crate::multipart::{self, PartName, MetadataFieldIterator};
61 pub use crate::utils::*;
62 pub use crate::queue::*;
63 pub use crate::reporter::*;
64 pub use crate::types::*;
65 pub use crate::slip::*;
66
67 pub type ReqNum = u64;
68
69 pub use ErrorKind as EK;
70 pub use PacketError as PE;
71 pub use tokio::io as t_io;
72 pub use tokio::process as t_proc;
73
74 pub const SLIP_END:     u8 = 0o300; // c0
75 pub const SLIP_ESC:     u8 = 0o333; // db
76 pub const SLIP_ESC_END: u8 = 0o334; // dc
77 pub const SLIP_ESC_ESC: u8 = 0o335; // dd
78 pub const SLIP_MIME_ESC: u8 = b'-'; // 2d
79
80 pub const MAX_OVERHEAD: usize = 2_000;
81
82 pub use base64::STANDARD as BASE64_CONFIG;
83
84 pub fn default<T:Default>() -> T { Default::default() }