Skip to main content

otter_support/
imports.rs

1// Copyright 2020-2021 Ian Jackson and contributors to Otter
2// SPDX-License-Identifier: AGPL-3.0-or-later
3// There is NO WARRANTY.
4
5// See Import Structure Doctrine in src/prelude.rs
6
7pub use std::borrow::Cow;
8pub use std::cmp::{self, max, min, Ordering};
9pub use std::collections::{hash_map, HashMap, HashSet};
10pub use std::collections::VecDeque;
11pub use std::collections::{btree_map, BTreeMap};
12pub use std::collections::{btree_set, BTreeSet};
13pub use std::env;
14pub use std::fs;
15pub use std::fs::File;
16pub use std::io;
17pub use std::io::ErrorKind;
18pub use std::io::{BufRead, BufReader, BufWriter, Read, Write};
19pub use std::marker::PhantomData;
20pub use std::net::{IpAddr, SocketAddr, ToSocketAddrs, Ipv6Addr, Ipv4Addr};
21pub use std::os::linux::fs::MetadataExt as _; // todo why linux for st_mode??
22pub use std::os::unix;
23pub use std::os::unix::ffi::OsStrExt;
24pub use std::os::unix::fs::{MetadataExt, OpenOptionsExt, PermissionsExt};
25pub use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
26pub use std::os::unix::net::UnixStream;
27pub use std::os::unix::process::{CommandExt, ExitStatusExt};
28pub use std::process::{exit, Child, Command, Stdio};
29pub use std::sync::Arc;
30pub use std::time::{self, Duration, Instant};
31
32pub use anyhow::{anyhow, ensure, Context};
33pub use byteorder::{BigEndian, LittleEndian, ReadBytesExt, WriteBytesExt};
34pub use derive_into_owned::IntoOwned;
35pub use digest::Digest;
36pub use flexi_logger::LogSpecification;
37pub use fs2::FileExt;
38pub use lazy_static::lazy_static;
39pub use log::{debug, error, info, trace, warn};
40pub use log::{log, log_enabled};
41pub use nix::unistd::{self, Uid};
42pub use nix::sys::time::TimeSpec;
43pub use nix::time::clock_gettime;
44pub use num_derive::{ToPrimitive, FromPrimitive};
45pub use num_traits::{cast, Bounded, FromPrimitive, ToPrimitive};
46pub use paste::paste;
47pub use rand::distributions::Alphanumeric;
48pub use rand::thread_rng;
49pub use rand::Rng;
50pub use rand::prelude::SliceRandom;
51pub use serde::ser::SerializeTuple;
52pub use serde::{de::DeserializeOwned, Deserialize, Serialize};
53pub use serde::de::Error as _;
54pub use serde::{Deserializer, Serializer};
55pub use serde_with::DeserializeFromStr;
56pub use serde_with::SerializeDisplay;
57pub use sha2::{Sha512, Sha512_256};
58pub use slotmap::{dense::DenseSlotMap, SparseSecondaryMap, Key as _};
59pub use strum::{EnumCount, EnumDiscriminants};
60pub use strum::{EnumString, EnumIter, EnumMessage, EnumProperty};
61pub use strum::{AsRefStr, IntoEnumIterator, IntoStaticStr};
62
63// No debug version of this
64pub use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
65
66// Swap this over for debugging
67pub use parking_lot::{Mutex, MutexGuard};
68//pub use crate::debugmutex::{Mutex, MutexGuard};
69
70pub use crate::matches_doesnot;
71pub use crate::trace_dbg;
72
73pub use crate::authproofs::{self, Authorisation, Unauthorised};
74pub use crate::authproofs::AuthorisationSuperuser;
75pub use crate::childio;
76pub use crate::config::*;
77pub use crate::debugmutex::DebugIdentify;
78pub use educe::Educe;
79pub use crate::digestrw::{self, *};
80pub use crate::fake_rng::*;
81pub use crate::fake_time::*;
82pub use crate::keydata::*;
83pub use crate::packetframe::{FrameReader, FrameWriter, ReadFrame, WriteFrame};
84pub use crate::packetframe::{ReadExt, ResponseWriter};
85pub use crate::packetframe::{PacketFrameReadError, PacketFrameWriteError};
86pub use crate::progress::{self, ProgressInfo, OriginatorExt as _};
87pub use crate::slotmap_slot_idx::*;
88pub use crate::support::*;
89pub use crate::termprogress::{self, Reporter as _};
90pub use crate::timedfd::*;
91pub use crate::toml_de;
92pub use crate::tz::*;
93
94pub type SecondarySlotMap<K,V> = slotmap::secondary::SecondaryMap<K,V>;
95pub type StartupError = anyhow::Error;
96
97pub const MS: time::Duration = time::Duration::from_millis(1);
98
99// ---------- type abbreviations ----------
100
101pub type AE = anyhow::Error;