chiark / gitweb /
crate structure: Introduce otter-support crate
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 May 2022 15:29:19 +0000 (16:29 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 14 May 2022 18:09:56 +0000 (19:09 +0100)
Currently this only has tz.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
24 files changed:
Cargo.lock
Cargo.toml
apitest/apitest.rs
base/lib.rs
base/prelude-part.rs [new file with mode: 0644]
base/prelude.rs
daemon/session.rs
src/gamestate.rs
src/imports.rs
src/lib.rs
src/prelude-part.rs [new file with mode: 0644]
src/prelude.rs
src/shapelib-toml.rs
src/shapelib.rs
src/slotmap-slot-idx.rs
src/spec.rs
src/toml-de.rs
src/utils.rs
support/Cargo.toml [new file with mode: 0644]
support/imports.rs [new file with mode: 0644]
support/lib.rs [new file with mode: 0644]
support/prelude-part.rs [new file with mode: 0644]
support/prelude.rs [new file with mode: 0644]
support/support.rs [new file with mode: 0644]

index 5b7bb5405a62ed7f2a762bcb8e59ed11ce9a43ed..4a8488c51c299fb39a97112013f0eebd6a64fd4d 100644 (file)
@@ -2681,8 +2681,6 @@ dependencies = [
  "bundle-sources",
  "byteorder",
  "cast_trait_object",
- "chrono",
- "chrono-tz",
  "console",
  "const-default",
  "crossbeam-utils",
@@ -2707,7 +2705,6 @@ dependencies = [
  "lazy-regex",
  "lazy_static",
  "libc",
- "log",
  "mio 0.8.2",
  "nix 0.23.1",
  "num",
@@ -2716,8 +2713,7 @@ dependencies = [
  "once_cell",
  "openssh-keys",
  "ordered-float",
- "otter-base",
- "parking_lot",
+ "otter-support",
  "paste",
  "percent-encoding",
  "pwd",
@@ -2734,6 +2730,7 @@ dependencies = [
  "subtle",
  "tempfile",
  "tera",
+ "thiserror",
  "toml",
  "typetag",
  "uds",
@@ -2831,6 +2828,20 @@ dependencies = [
  "structopt",
 ]
 
+[[package]]
+name = "otter-support"
+version = "1.0.0"
+dependencies = [
+ "chrono",
+ "chrono-tz",
+ "fehler",
+ "log",
+ "otter-base",
+ "parking_lot",
+ "serde",
+ "serde_with",
+]
+
 [[package]]
 name = "otter-wasm"
 version = "1.0.0"
index 153f30d6b3f1effa7564f52413e7375fb89025e3..e696f42fe4fca0b1622d952ae563bbf0e3da78eb 100644 (file)
@@ -4,7 +4,7 @@
 
 [package]
 name="otter"
-description="Otter game system; common infrastructure Rust crate."
+description="Otter game system; main data structures Rust crate."
 
 version="1.0.0"
 license="AGPL-3.0-or-later"
@@ -29,8 +29,8 @@ bundle-sources="0.0.1"
 
 [dependencies]
 
-otter-base.path="base"
-otter-base.version="=1.0.0"
+otter-support.path="support"
+otter-support.version="=1.0.0"
        
 anyhow="1"
 backtrace="0.3"
@@ -38,8 +38,6 @@ base64="0.13"
 boolinator="2"
 byteorder="1.3"
 cast_trait_object="0.1"
-chrono="0.4"
-chrono-tz="0.6"
 console="0.15"
 crossbeam-utils="0.8"
 delegate="0.6"
@@ -50,7 +48,6 @@ educe="0.4"
 either="1"
 enum_dispatch="0.3.5"
 env_logger="0.9"
-fehler="1"
 fs2="0.4"
 glob="0.3"
 humantime-serde="1"
@@ -59,7 +56,6 @@ lazy-init="0.5"
 lazy-regex="2"
 lazy_static="1"
 libc="0.2"
-log="0.4"
 nix="0.23"
 num="0.4"
 num-derive="0.3"
@@ -68,14 +64,12 @@ once_cell="1"
 openssh-keys="0.5"
 ordered-float="2"
 paste="1"
-parking_lot="0.12"
 percent-encoding="2"
 pwd="1"
 rand="0.8"
 regex="1"
 rmp="0.8"
 rmp-serde="1"
-serde_with="1"
 structopt="0.3"
 sha2="0.10"
 subtle="2.4"
@@ -100,9 +94,14 @@ flexi_logger = { version="0.22" , features=["specfile"    ] }
 image = { version = "0.24", default-features=false, features=["jpeg","png"] }
 index_vec    = { version="0.1.1", features=["serde"       ] }
 mio          = { version="0.8",   features=["os-ext", "os-poll" ] }
-serde        = { version="1"    , features=["derive", "rc"] }
 strum        = { version="0.24" , features=["derive"      ] }
 
 slotmap = { package="slotmap-fork-otter", version="1", git="https://github.com/ijackson/slotmap", branch="slotmap-fork-otter", features=["serde"] }
 
+# Repeated in other Cargo.toml's because importing does not work properly
+fehler="1"
+serde        = { version="1"    , features=["derive", "rc"] }
+serde_with="1"
+thiserror="1"
+
 #fin.
index 9819759fa85a41298cf93990d68c565038504196..ca3337ff68c94d86c95a42f7284b89af783462d2 100644 (file)
@@ -346,6 +346,7 @@ impl<T,E> Result<T,E> {
 pub mod cleanup_notify {
   use super::imports::*;
   use super::AE;
+  pub use super::Void; // TODO remove the need for this
 
   use anyhow::Context;
   use fehler::{throw, throws};
@@ -353,7 +354,6 @@ pub mod cleanup_notify {
   use nix::{unistd::*, fcntl::OFlag};
   use nix::sys::signal::*;
   use nix::Error as NE;
-  use void::Void;
   use std::io;
   use std::os::unix::io::RawFd;
   use std::panic::catch_unwind;
index 2366f15c02b4ccc981f23f94d70ee54afcaefbe1..be02056aba5696c6b20ffe6d5e1dc2419f3f89fd 100644 (file)
@@ -14,6 +14,9 @@
 pub mod imports;
 pub mod prelude;
 
+#[path="prelude-part.rs"]
+pub mod prelude_part;
+
 pub mod geometry;
 pub mod html;
 pub mod zcoord;
diff --git a/base/prelude-part.rs b/base/prelude-part.rs
new file mode 100644 (file)
index 0000000..5b99918
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright 2020-2021 Ian Jackson and contributors to Otter
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+pub use std::borrow::Borrow;
+pub use std::cmp::{max, Ordering};
+pub use std::convert::{TryFrom, TryInto};
+pub use std::f64::consts::TAU;
+pub use std::fmt::{self, Debug, Display, Formatter, Write as _};
+pub use std::hash::{Hash, Hasher};
+pub use std::iter::{self, FusedIterator};
+pub use std::mem;
+pub use std::num::{TryFromIntError, Wrapping};
+pub use std::ops::{Deref, DerefMut, Index, IndexMut};
+pub use std::str;
+pub use std::str::FromStr;
+
+pub use arrayvec::ArrayVec;
+pub use derive_more::*;
+pub use extend::ext;
+pub use fehler::{throw, throws};
+pub use if_chain::if_chain;
+pub use itertools::{chain, iproduct, izip, zip_eq, EitherOrBoth, Itertools};
+pub use serde::{Deserialize, Serialize};
+pub use serde_with::DeserializeFromStr;
+pub use serde_with::SerializeDisplay;
+pub use thiserror::Error;
+pub use void::Void;
+
+pub use crate::html::*;
+
+pub use crate::{pos_zip_map, pos_zip_try_map};
+pub use crate::geometry::{CoordinateOverflow, PosC, PosPromote};
+pub use crate::{dbgc, hformat, hformat_as_display, hwrite};
+pub use crate::misc::default;
+pub use crate::misc::display_as_debug;
+
+pub use crate::if_let;
index 5355dfda30fdf2ec1c17f163a4569d7c74755052..01726c19e237a1f5c73e7b96cf9a8577cb14c245 100644 (file)
@@ -2,37 +2,5 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
-pub use std::borrow::Borrow;
-pub use std::cmp::{max, Ordering};
-pub use std::convert::{TryFrom, TryInto};
-pub use std::f64::consts::TAU;
-pub use std::fmt::{self, Debug, Display, Formatter, Write as _};
-pub use std::hash::{Hash, Hasher};
-pub use std::iter::{self, FusedIterator};
-pub use std::mem;
-pub use std::num::{TryFromIntError, Wrapping};
-pub use std::ops::{Deref, DerefMut, Index, IndexMut};
-pub use std::str;
-pub use std::str::FromStr;
-
-pub use arrayvec::ArrayVec;
-pub use derive_more::*;
-pub use extend::ext;
-pub use fehler::{throw, throws};
-pub use if_chain::if_chain;
-pub use itertools::izip;
-pub use serde::{Deserialize, Serialize};
-pub use serde_with::DeserializeFromStr;
-pub use serde_with::SerializeDisplay;
-pub use thiserror::Error;
-pub use void::{self, Void};
-
-pub use crate::html::*;
-
-pub use crate::{pos_zip_map, pos_zip_try_map};
-pub use crate::geometry::{CoordinateOverflow, PosC, PosPromote};
-pub use crate::{dbgc, hformat, hformat_as_display, hwrite};
-pub use crate::misc::default;
-pub use crate::misc::display_as_debug;
-
-pub use crate::if_let;
+pub use crate::imports::*;
+pub use crate::prelude_part::*;
index aa6172de05af899ac1447eba008495dd8c305d8b..b8903b8408edc989b70722b845ce9d9771781557 100644 (file)
@@ -2,7 +2,7 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
-use crate::imports::*;
+//use crate::imports::*;
 
 use super::*;
 
index 83ed3799599be9f29a094f9b117301c28a03b35a..e215250faa0dddb6ffaa65885e1994431f249292 100644 (file)
@@ -19,10 +19,6 @@ pub struct Generation(pub u64);
 
 visible_slotmap_key!{ VisiblePieceId(b'.') }
 
-#[derive(Copy,Clone,Debug,Serialize,Deserialize,Eq,Ord,PartialEq,PartialOrd)]
-#[serde(transparent)]
-pub struct Timestamp(pub u64); /* time_t */
-
 #[derive(Copy,Clone,Debug,Eq,Ord,PartialEq,PartialOrd)]
 pub struct SpecDepth(u16);
 
@@ -408,22 +404,6 @@ impl SpecDepth {
   }
 }
 
-impl Timestamp {
-  /// Always >= previously
-  pub fn now() -> Timestamp {
-    use std::time::SystemTime;
-    let now = SystemTime::now()
-      .duration_since(SystemTime::UNIX_EPOCH)
-      .unwrap()
-      .as_secs();
-    Timestamp(now)
-  }
-
-  pub fn render(&self, tz: &Timezone) -> String {
-    tz.format(*self)
-  }
-}
-
 #[derive(Error, Debug)]
 #[error("{self:?}")]
 pub struct PieceTraitDowncastFailed<'p> {
index 7c402af609236e2d2847e959b6c07ffdc526c1f4..0df7da8a29c656a50df8e19a90b9540de53566ae 100644 (file)
@@ -2,16 +2,13 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
-pub use otter_base;
-pub use otter_base::imports::*;
+pub use otter_support;
 
 pub use anyhow;
 pub use async_condvar_fair;
 pub use base64;
 pub use boolinator;
 pub use cast_trait_object;
-pub use chrono;
-pub use chrono_tz;
 pub use delegate;
 pub use digest;
 pub use educe;
@@ -26,11 +23,9 @@ pub use lazy_init;
 pub use lazy_static;
 pub use inventory;
 pub use libc;
-pub use log;
 pub use nix;
 pub use once_cell;
 pub use ordered_float;
-pub use parking_lot;
 pub use pwd;
 pub use regex;
 pub use rmp_serde;
index 3c6b129e8c22686e61718779318b4fe2d5368395..76f80d0215e1c680e6c13e070e5b33a9b9ee3d4c 100644 (file)
@@ -21,6 +21,9 @@
 pub mod imports;
 pub mod prelude;
 
+#[path="prelude-part.rs"]
+pub mod prelude_part;
+
 pub mod accounts;
 pub mod asseturl;
 pub mod authproofs;
@@ -55,7 +58,6 @@ pub mod shapelib;
 pub mod spec;
 pub mod termprogress;
 pub mod timedfd;
-pub mod tz;
 pub mod updates;
 pub mod ui;
 pub mod utils;
diff --git a/src/prelude-part.rs b/src/prelude-part.rs
new file mode 100644 (file)
index 0000000..1e583f4
--- /dev/null
@@ -0,0 +1,235 @@
+// Copyright 2020-2021 Ian Jackson and contributors to Otter
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+use crate::imports::*;
+use otter_support::imports::*;
+use otter_base::imports::*;
+
+use otter_base::prelude_part::*;
+
+pub use std::any::Any;
+pub use std::borrow::Cow;
+pub use std::cmp::{self, max, min, Ordering};
+pub use std::collections::VecDeque;
+pub use std::collections::{btree_map, BTreeMap};
+pub use std::collections::{btree_set, BTreeSet};
+pub use std::convert::{Infallible, TryFrom, TryInto};
+pub use std::env;
+pub use std::error::Error;
+pub use std::ffi::OsStr;
+pub use std::fmt::Formatter;
+pub use std::fmt::Write as _;
+pub use std::fmt::{self, Debug, Display};
+pub use std::fs;
+pub use std::fs::File;
+pub use std::hash::Hash;
+pub use std::io;
+pub use std::io::ErrorKind;
+pub use std::io::{BufRead, BufReader, BufWriter, Read, Write};
+pub use std::iter;
+pub use std::iter::{repeat_with};
+pub use std::marker::PhantomData;
+pub use std::num::{NonZeroUsize, TryFromIntError, Wrapping};
+pub use std::os::linux::fs::MetadataExt as _; // todo why linux for st_mode??
+pub use std::os::unix;
+pub use std::os::unix::ffi::OsStrExt;
+pub use std::os::unix::fs::{MetadataExt, OpenOptionsExt};
+pub use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
+pub use std::os::unix::net::UnixStream;
+pub use std::os::unix::process::{CommandExt, ExitStatusExt};
+pub use std::net::{IpAddr, SocketAddr, ToSocketAddrs, Ipv6Addr, Ipv4Addr};
+pub use std::path::PathBuf;
+pub use std::process::{exit, Child, Command, Stdio};
+pub use std::str;
+pub use std::str::FromStr;
+pub use std::string::ParseError;
+pub use std::sync::atomic::AtomicBool;
+pub use std::sync::mpsc;
+pub use std::thread::{self, sleep};
+pub use std::time::{self, Duration, Instant};
+
+pub use anyhow::{anyhow, ensure, Context};
+pub use async_condvar_fair::{Condvar, BatonExt as _};
+pub use boolinator::Boolinator as _;
+pub use byteorder::{BigEndian, LittleEndian, ReadBytesExt, WriteBytesExt};
+pub use cast_trait_object::{dyn_upcast, DynCastExt};
+pub use const_default::ConstDefault;
+pub use delegate::delegate;
+pub use derive_into_owned::IntoOwned;
+pub use digest::Digest;
+pub use downcast_rs::{impl_downcast, Downcast};
+pub use educe::Educe;
+pub use either::{Either, Left, Right};
+pub use enum_dispatch::enum_dispatch;
+pub use enum_map::{Enum, EnumMap};
+pub use fehler::{throw, throws};
+pub use flexi_logger::LogSpecification;
+pub use fs2::FileExt;
+pub use index_vec::{define_index_type, index_vec, IndexSlice, IndexVec};
+pub use lazy_regex::regex;
+pub use lazy_static::lazy_static;
+pub use log::{log, log_enabled};
+pub use nix::unistd::{self, Uid};
+pub use nix::sys::time::TimeSpec;
+pub use nix::time::clock_gettime;
+pub use num_derive::{ToPrimitive, FromPrimitive};
+pub use num_traits::{Bounded, FromPrimitive, ToPrimitive};
+pub use ordered_float::OrderedFloat;
+pub use paste::paste;
+pub use percent_encoding::percent_decode_str;
+pub use percent_encoding::utf8_percent_encode;
+pub use percent_encoding::NON_ALPHANUMERIC;
+pub use rand::distributions::Alphanumeric;
+pub use rand::thread_rng;
+pub use rand::Rng;
+pub use rand::prelude::SliceRandom;
+pub use regex::Regex;
+pub use sha2::{Sha512, Sha512_256};
+pub use slotmap::{dense::DenseSlotMap, SparseSecondaryMap, Key as _};
+pub use strum::{EnumCount, EnumDiscriminants};
+pub use strum::{EnumString, EnumIter, EnumMessage, EnumProperty};
+pub use strum::{AsRefStr, IntoEnumIterator, IntoStaticStr};
+pub use subtle::ConstantTimeEq;
+pub use tempfile::{self, NamedTempFile};
+pub use tera::Tera;
+pub use unicase::UniCase;
+pub use url::Url;
+pub use vecdeque_stableix::Deque as StableIndexVecDeque;
+pub use vecdeque_stableix::Offset as StableIndexOffset;
+pub use void::{unreachable, Void, ResultVoidExt, ResultVoidErrExt};
+pub use crate::imports::zipfile::{self, read::ZipFile, result::ZipError};
+
+use nix::time::ClockId;
+pub const CLOCK_REALTIME : ClockId = ClockId::CLOCK_REALTIME ;
+pub const CLOCK_MONOTONIC: ClockId = ClockId::CLOCK_MONOTONIC;
+
+pub use otter_base::{pos_zip_map, pos_zip_try_map};
+pub use otter_base::geometry::{self,Coord,Pos,PosC,Rect,RectC};
+pub use otter_base::geometry::{CoordinateOverflow,Region};
+pub use otter_base::zcoord::{self, ZCoord};
+pub use otter_base::misc as base_misc;
+pub use otter_base::dbgc;
+pub use base_misc::*;
+
+pub use crate::{deref_to_field, deref_to_field_mut};
+pub use crate::ensure_eq;
+pub use crate::format_by_fmt_hex;
+pub use crate::impl_via_ambassador;
+pub use crate::matches_doesnot;
+pub use crate::trace_dbg;
+pub use crate::{want, wantok, wants, want_let, want_failed_internal};
+pub use crate::serde_with_compat;
+
+pub use crate::accounts::loaded_acl::{self, EffectiveACL, LoadedAcl, PermSet};
+pub use crate::accounts::*;
+pub use crate::authproofs::{self, Authorisation, Unauthorised};
+pub use crate::authproofs::AuthorisationSuperuser;
+pub use crate::asseturl::*;
+pub use crate::bundles::{self, InstanceBundles, MgmtBundleListExt};
+pub use crate::childio;
+pub use crate::commands::{AccessTokenInfo, AccessTokenReport, MgmtError};
+pub use crate::commands::{MgmtCommand, MgmtResponse};
+pub use crate::commands::{MgmtGameInstruction, MgmtGameResponse};
+pub use crate::commands::{MgmtBundleList, MgmtGameUpdateMode};
+pub use crate::commands::{ProgressUpdateMode};
+pub use crate::config::*;
+pub use crate::debugmutex::DebugIdentify;
+pub use crate::debugreader::DebugReader;
+pub use crate::digestrw::{self, *};
+pub use crate::error::*;
+pub use crate::fake_rng::*;
+pub use crate::fake_time::*;
+pub use crate::fastsplit::*;
+pub use crate::gamestate::*;
+pub use crate::global::*;
+pub use crate::hidden::*;
+pub use crate::keydata::*;
+pub use crate::nwtemplates;
+pub use crate::materials_format;
+pub use crate::mgmtchannel::*;
+pub use crate::occultilks::*;
+pub use crate::organise;
+pub use crate::packetframe::{FrameReader, FrameWriter, ReadFrame, WriteFrame};
+pub use crate::packetframe::{ReadExt, ResponseWriter};
+pub use crate::pcaliases::*;
+pub use crate::pcrender::*;
+pub use crate::pieces::*;
+pub use crate::progress::{self, ProgressInfo, OriginatorExt as _};
+pub use crate::shapelib;
+pub use crate::shapelib::{CircleShape, RectShape};
+pub use crate::shapelib::{ItemEnquiryData, LibraryEnquiryData};
+pub use crate::shapelib::{LibraryLoadError};
+pub use crate::slotmap_slot_idx::*;
+pub use crate::spec::*;
+pub use crate::spec::piece_specs::{FaceColourSpecs, SimpleCommon};
+pub use crate::toml_de;
+pub use crate::timedfd::*;
+pub use crate::termprogress;
+pub use crate::updates::*;
+pub use crate::utils::*;
+pub use crate::ui::*;
+
+pub use crate::gamestate::RefTraitObjectPieceTraitExt as _;
+pub use crate::fastsplit::RefTraitObjectPieceTraitExt as _;
+
+pub type SecondarySlotMap<K,V> = slotmap::secondary::SecondaryMap<K,V>;
+pub type SvgData = Vec<u8>;
+pub type Colour = Html;
+
+pub const MS: time::Duration = time::Duration::from_millis(1);
+
+// ---------- type abbreviations ----------
+
+pub type AE = anyhow::Error;
+
+// accounts.rs
+pub type AS = AccountScope;
+
+// commands.rs
+pub type MC = MgmtCommand;
+pub type ME = MgmtError;
+pub type MGI = MgmtGameInstruction;
+pub type MGR = MgmtGameResponse;
+pub type MR = MgmtResponse;
+pub type PUM = ProgressUpdateMode;
+
+// error.rs
+pub type APOE = ApiPieceOpError;
+pub type ESVU<POEPU,EM> = ErrorSignaledViaUpdate<POEPU,EM>;
+pub type IE = InternalError;
+pub type Ia = Inapplicable;
+pub type POEPP = PieceOpErrorPartiallyProcessed;
+pub type SvgE = SVGProcessingError;
+pub type SpE = SpecError;
+
+// gamestate.rs
+pub use PieceLoadArgs as PLA;
+
+// hidden.rs
+pub type OccK = OccultationKind;
+pub use OccultationKindGeneral as OccKG;
+pub use OccultationKindAlwaysOk as OccKA;
+
+// materials-format.rs
+
+pub use materials_format::VersionError as MFVE;
+
+// occultilks.rs
+pub type LOI = LOccultIlk;
+pub type IOI = IOccultIlk;
+
+// pcrender.rs
+pub use PriOccultedGeneral as PriOG;
+
+// updates.rs
+pub use OpOutcomeThunkGeneric as OOTG;
+pub type PUE = PreparedUpdateEntry;
+pub type PUFOS = PieceUpdateFromOpSimple;
+pub type PUO<NS,ZL> = PieceUpdateOp<NS,ZL>;
+pub type PUOs = PieceUpdateOps;
+pub type WRC = WhatResponseToClientOp;
+#[allow(non_camel_case_types)] pub type PUE_P = PreparedUpdateEntry_Piece;
+
+// utils.rs
+pub use SVGSizeError as SvSE;
index d48a9cb819a73d0ee8e3063817cb7369c700f597..74d83ff7c1c196554c66191ab6cbe88c09a309ef 100644 (file)
 // There is NO WARRANTY.
 
 pub use crate::imports::*;
-pub use otter_base::prelude::*;
+pub use crate::prelude_part::*;
 
-pub use std::any::Any;
-pub use std::borrow::Cow;
-pub use std::cmp::{self, max, min, Ordering};
-pub use std::collections::VecDeque;
-pub use std::collections::{btree_map, BTreeMap};
-pub use std::collections::{btree_set, BTreeSet};
-pub use std::collections::{hash_map, HashMap, HashSet};
-pub use std::convert::{Infallible, TryFrom, TryInto};
-pub use std::env;
-pub use std::error::Error;
-pub use std::ffi::OsStr;
-pub use std::fmt::Formatter;
-pub use std::fmt::Write as _;
-pub use std::fmt::{self, Debug, Display};
-pub use std::fs;
-pub use std::fs::File;
-pub use std::hash::Hash;
-pub use std::io;
-pub use std::io::ErrorKind;
-pub use std::io::{BufRead, BufReader, BufWriter, Read, Write};
-pub use std::iter;
-pub use std::iter::{repeat_with};
-pub use std::marker::PhantomData;
-pub use std::num::{NonZeroUsize, TryFromIntError, Wrapping};
-pub use std::os::linux::fs::MetadataExt as _; // todo why linux for st_mode??
-pub use std::os::unix;
-pub use std::os::unix::ffi::OsStrExt;
-pub use std::os::unix::fs::{MetadataExt, OpenOptionsExt};
-pub use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
-pub use std::os::unix::net::UnixStream;
-pub use std::os::unix::process::{CommandExt, ExitStatusExt};
-pub use std::net::{IpAddr, SocketAddr, ToSocketAddrs, Ipv6Addr, Ipv4Addr};
-pub use std::path::PathBuf;
-pub use std::process::{exit, Child, Command, Stdio};
-pub use std::str;
-pub use std::str::FromStr;
-pub use std::string::ParseError;
-pub use std::sync::Arc;
-pub use std::sync::atomic::AtomicBool;
-pub use std::sync::mpsc;
-pub use std::thread::{self, sleep};
-pub use std::time::{self, Duration, Instant};
+pub use otter_base::imports::*;
+pub use otter_base::prelude_part::*;
 
-pub use anyhow::{anyhow, ensure, Context};
-pub use async_condvar_fair::{Condvar, BatonExt as _};
-pub use arrayvec::ArrayVec;
-pub use boolinator::Boolinator as _;
-pub use byteorder::{BigEndian, LittleEndian, ReadBytesExt, WriteBytesExt};
-pub use cast_trait_object::{dyn_upcast, DynCastExt};
-pub use const_default::ConstDefault;
-pub use delegate::delegate;
-pub use derive_into_owned::IntoOwned;
-pub use derive_more::*;
-pub use digest::Digest;
-pub use downcast_rs::{impl_downcast, Downcast};
-pub use educe::Educe;
-pub use either::{Either, Left, Right};
-pub use enum_dispatch::enum_dispatch;
-pub use enum_map::{Enum, EnumMap};
-pub use fehler::{throw, throws};
-pub use flexi_logger::LogSpecification;
-pub use fs2::FileExt;
-pub use if_chain::if_chain;
-pub use index_vec::{define_index_type, index_vec, IndexSlice, IndexVec};
-pub use itertools::{chain, iproduct, izip, zip_eq, EitherOrBoth, Itertools};
-pub use lazy_regex::regex;
-pub use lazy_static::lazy_static;
-pub use log::{debug, error, info, trace, warn};
-pub use log::{log, log_enabled};
-pub use nix::unistd::{self, Uid};
-pub use nix::sys::time::TimeSpec;
-pub use nix::time::clock_gettime;
-pub use num_derive::{ToPrimitive, FromPrimitive};
-pub use num_traits::{Bounded, FromPrimitive, ToPrimitive};
-pub use ordered_float::OrderedFloat;
-pub use paste::paste;
-pub use percent_encoding::percent_decode_str;
-pub use percent_encoding::utf8_percent_encode;
-pub use percent_encoding::NON_ALPHANUMERIC;
-pub use rand::distributions::Alphanumeric;
-pub use rand::thread_rng;
-pub use rand::Rng;
-pub use rand::prelude::SliceRandom;
-pub use regex::Regex;
-pub use serde::ser::SerializeTuple;
-pub use serde::{de::DeserializeOwned, Deserialize, Serialize};
-pub use serde::de::Error as _;
-pub use serde::{Deserializer, Serializer};
-pub use serde_with::DeserializeFromStr;
-pub use serde_with::SerializeDisplay;
-pub use sha2::{Sha512, Sha512_256};
-pub use slotmap::{dense::DenseSlotMap, SparseSecondaryMap, Key as _};
-pub use strum::{EnumCount, EnumDiscriminants};
-pub use strum::{EnumString, EnumIter, EnumMessage, EnumProperty};
-pub use strum::{AsRefStr, IntoEnumIterator, IntoStaticStr};
-pub use subtle::ConstantTimeEq;
-pub use tempfile::{self, NamedTempFile};
-pub use tera::Tera;
-pub use thiserror::Error;
-pub use unicase::UniCase;
-pub use url::Url;
-pub use vecdeque_stableix::Deque as StableIndexVecDeque;
-pub use vecdeque_stableix::Offset as StableIndexOffset;
-pub use void::{unreachable, Void, ResultVoidExt, ResultVoidErrExt};
-pub use crate::imports::zipfile::{self, read::ZipFile, result::ZipError};
+pub use otter_support::imports::*;
+pub use otter_support::prelude_part::*;
 
-// No debug version of this
-pub use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
-
-// Swap this over for debugging
-pub use parking_lot::{Mutex, MutexGuard};
-//pub use crate::debugmutex::{Mutex, MutexGuard};
-
-use nix::time::ClockId;
-pub const CLOCK_REALTIME : ClockId = ClockId::CLOCK_REALTIME ;
-pub const CLOCK_MONOTONIC: ClockId = ClockId::CLOCK_MONOTONIC;
-
-pub use otter_base::{pos_zip_map, pos_zip_try_map};
-pub use otter_base::geometry::{self,Coord,Pos,PosC,Rect,RectC};
-pub use otter_base::geometry::{CoordinateOverflow,Region};
-pub use otter_base::zcoord::{self, ZCoord};
-pub use otter_base::misc as base_misc;
-pub use otter_base::dbgc;
-pub use base_misc::*;
-
-pub use crate::{deref_to_field, deref_to_field_mut};
-pub use crate::ensure_eq;
-pub use crate::format_by_fmt_hex;
-pub use crate::impl_via_ambassador;
-pub use crate::matches_doesnot;
-pub use crate::trace_dbg;
-pub use crate::{want, wantok, wants, want_let, want_failed_internal};
-pub use crate::serde_with_compat;
-
-pub use crate::accounts::loaded_acl::{self, EffectiveACL, LoadedAcl, PermSet};
-pub use crate::accounts::*;
-pub use crate::authproofs::{self, Authorisation, Unauthorised};
-pub use crate::authproofs::AuthorisationSuperuser;
-pub use crate::asseturl::*;
-pub use crate::bundles::{self, InstanceBundles, MgmtBundleListExt};
-pub use crate::childio;
-pub use crate::commands::{AccessTokenInfo, AccessTokenReport, MgmtError};
-pub use crate::commands::{MgmtCommand, MgmtResponse};
-pub use crate::commands::{MgmtGameInstruction, MgmtGameResponse};
-pub use crate::commands::{MgmtBundleList, MgmtGameUpdateMode};
-pub use crate::commands::{ProgressUpdateMode};
-pub use crate::config::*;
-pub use crate::debugmutex::DebugIdentify;
-pub use crate::debugreader::DebugReader;
-pub use crate::digestrw::{self, *};
-pub use crate::error::*;
-pub use crate::fake_rng::*;
-pub use crate::fake_time::*;
-pub use crate::fastsplit::*;
-pub use crate::gamestate::*;
-pub use crate::global::*;
-pub use crate::hidden::*;
-pub use crate::keydata::*;
-pub use crate::nwtemplates;
-pub use crate::materials_format;
-pub use crate::mgmtchannel::*;
-pub use crate::occultilks::*;
-pub use crate::organise;
-pub use crate::packetframe::{FrameReader, FrameWriter, ReadFrame, WriteFrame};
-pub use crate::packetframe::{ReadExt, ResponseWriter};
-pub use crate::pcaliases::*;
-pub use crate::pcrender::*;
-pub use crate::pieces::*;
-pub use crate::progress::{self, ProgressInfo, OriginatorExt as _};
-pub use crate::shapelib;
-pub use crate::shapelib::{CircleShape, RectShape};
-pub use crate::shapelib::{ItemEnquiryData, LibraryEnquiryData};
-pub use crate::shapelib::{LibraryLoadError};
-pub use crate::slotmap_slot_idx::*;
-pub use crate::spec::*;
-pub use crate::spec::piece_specs::{FaceColourSpecs, SimpleCommon};
-pub use crate::toml_de;
-pub use crate::timedfd::*;
-pub use crate::termprogress;
-pub use crate::tz::*;
-pub use crate::updates::*;
-pub use crate::utils::*;
-pub use crate::ui::*;
-
-pub use crate::gamestate::RefTraitObjectPieceTraitExt as _;
-pub use crate::fastsplit::RefTraitObjectPieceTraitExt as _;
-
-pub type SecondarySlotMap<K,V> = slotmap::secondary::SecondaryMap<K,V>;
-pub type SvgData = Vec<u8>;
-pub type Colour = Html;
-
-pub const MS: time::Duration = time::Duration::from_millis(1);
-
-// ---------- type abbreviations ----------
-
-pub type AE = anyhow::Error;
-
-// accounts.rs
-pub type AS = AccountScope;
-
-// commands.rs
-pub type MC = MgmtCommand;
-pub type ME = MgmtError;
-pub type MGI = MgmtGameInstruction;
-pub type MGR = MgmtGameResponse;
-pub type MR = MgmtResponse;
-pub type PUM = ProgressUpdateMode;
-
-// error.rs
-pub type APOE = ApiPieceOpError;
-pub type ESVU<POEPU,EM> = ErrorSignaledViaUpdate<POEPU,EM>;
-pub type IE = InternalError;
-pub type Ia = Inapplicable;
-pub type POEPP = PieceOpErrorPartiallyProcessed;
-pub type SvgE = SVGProcessingError;
-pub type SpE = SpecError;
-
-// gamestate.rs
-pub use PieceLoadArgs as PLA;
-
-// hidden.rs
-pub type OccK = OccultationKind;
-pub use OccultationKindGeneral as OccKG;
-pub use OccultationKindAlwaysOk as OccKA;
-
-// materials-format.rs
-
-pub use materials_format::VersionError as MFVE;
-
-// occultilks.rs
-pub type LOI = LOccultIlk;
-pub type IOI = IOccultIlk;
-
-// pcrender.rs
-pub use PriOccultedGeneral as PriOG;
-
-// updates.rs
-pub use OpOutcomeThunkGeneric as OOTG;
-pub type PUE = PreparedUpdateEntry;
-pub type PUFOS = PieceUpdateFromOpSimple;
-pub type PUO<NS,ZL> = PieceUpdateOp<NS,ZL>;
-pub type PUOs = PieceUpdateOps;
-pub type WRC = WhatResponseToClientOp;
-#[allow(non_camel_case_types)] pub type PUE_P = PreparedUpdateEntry_Piece;
-
-// utils.rs
-pub use SVGSizeError as SvSE;
index 367ac6289574ae2b30a60af03f0584b9f34fa243..bd5e71be5135ca189ec817ac2b49778b7dbcc34b 100644 (file)
@@ -2,7 +2,7 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
-pub use crate::prelude::*;
+use crate::prelude::*;
 
 use shapelib::OutlineDefnEnum;
 
index 110a988df7ecef39577ae75170e0ddfe9b912ea2..475819f217d070363686e74a132d686d6ff5315c 100644 (file)
@@ -2,9 +2,11 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
-pub use crate::prelude::*;
+use crate::prelude::*;
 pub use crate::shapelib_toml::*;
 
+pub use crate::prelude::GoodItemName; // not sure why this is needed
+
 use parking_lot::{const_rwlock, RwLock};
 use parking_lot::RwLockReadGuard;
 
index 64cf5fed064abd4abed7eb43b40e695f09ba3dfd..12812ee93c736f949a69a2f5bb40d5ea4f5690fd 100644 (file)
@@ -7,7 +7,7 @@
 //! Provides a [`get_idx_key`](trait.KeyDataExt.html#tymethod.get_idx_version) method on
 //! `slotmap::KeyData`.  See [KeyDataExt::get_idx_version].
 
-use otter_base::misc::default;
+use crate::prelude::otter_base::misc::default;
 
 /// Extension trait for `slotmap::KeyData`, providing `get_idx_version`.
 ///
index b259cbf1d94134f383c19cde404ca9609ffa6df1..5cb6985e96d3b15fae8260fb35e19f9b82c08bc8 100644 (file)
@@ -5,6 +5,8 @@
 // game specs
 
 use crate::imports::*;
+use otter_support::imports::*;
+use otter_base::imports::*;
 
 use std::borrow::Cow;
 use std::collections::hash_map::HashMap;
index a1310e1709454e340f81e82734be3301827f396f..589938d0b2f01a5322e59c8f838b0349ae1772bc 100644 (file)
@@ -3,6 +3,8 @@
 // There is NO WARRANTY.
 
 use crate::imports::*;
+use otter_support::imports::*;
+use otter_base::imports::*;
 
 use std::fmt::{Debug, Display};
 use std::iter::Peekable;
index 8c5f58beadd38667bae191e3b06e66e9bd392ee0..c50e756e77e985560ba7552ced46b59785238414 100644 (file)
@@ -2,9 +2,10 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
-use crate::imports::*;
 use crate::prelude::*;
 
+pub use otter_base::imports::extend::ext;
+
 //========== miscellany ==========
 // (roughly in order of implementation length)
 
@@ -407,7 +408,7 @@ macro_rules! entry_define_insert_remove {
   {
     #[allow(non_snake_case)]
     mod $name_mod {
-      use $crate::imports::extend::ext;
+      use $crate::prelude::extend::ext;
       use $entry as Entry;
       use Entry::{Occupied, Vacant};
       #[ext(pub, name=EntryExt)]
diff --git a/support/Cargo.toml b/support/Cargo.toml
new file mode 100644 (file)
index 0000000..d748536
--- /dev/null
@@ -0,0 +1,39 @@
+# Copyright 2020-2021 Ian Jackson and contributors to Otter
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# There is NO WARRANTY.
+
+[package]
+name="otter-support"
+description="Otter game system; support code Rust crate."
+
+version="1.0.0"
+license="AGPL-3.0-or-later"
+edition="2021"
+resolver="1" # new resolver crashes!
+homepage="https://www.chiark.greenend.org.uk/~ianmdlvl/otter/docs/"
+repository="https://salsa.debian.org/iwj/otter"
+keywords=["games"]
+authors=["Ian Jackson <ijackson@chiark.greenend.org.uk>",
+         "and the contributors to Otter"]
+
+[lib]
+name="otter_support"
+path="lib.rs"
+
+
+[dependencies]
+
+otter-base.path="../base"
+otter-base.version="=1.0.0"
+       
+chrono="0.4"
+chrono-tz="0.6"
+fehler="1"
+log="0.4"
+parking_lot="0.12"
+
+serde_with="1"
+
+serde        = { version="1"    , features=["derive", "rc"] }
+
+#fin.
diff --git a/support/imports.rs b/support/imports.rs
new file mode 100644 (file)
index 0000000..bc76d96
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2020-2021 Ian Jackson and contributors to Otter
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+pub use otter_base;
+
+pub use chrono;
+pub use chrono_tz;
+pub use log;
+pub use parking_lot;
diff --git a/support/lib.rs b/support/lib.rs
new file mode 100644 (file)
index 0000000..d06e385
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2020-2021 Ian Jackson and contributors to Otter
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+pub mod imports;
+pub mod prelude;
+
+#[path="prelude-part.rs"]
+pub mod prelude_part;
+
+pub mod support;
+
+#[path="../src/tz.rs"] pub mod tz;
diff --git a/support/prelude-part.rs b/support/prelude-part.rs
new file mode 100644 (file)
index 0000000..fb422a5
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2020-2021 Ian Jackson and contributors to Otter
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+pub use std::collections::{hash_map, HashMap, HashSet};
+pub use std::sync::Arc;
+
+pub use log::{debug, error, info, trace, warn};
+pub use serde::ser::SerializeTuple;
+pub use serde::{de::DeserializeOwned, Deserialize, Serialize};
+pub use serde::de::Error as _;
+pub use serde::{Deserializer, Serializer};
+pub use serde_with::DeserializeFromStr;
+pub use serde_with::SerializeDisplay;
+
+// No debug version of this
+pub use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
+
+// Swap this over for debugging
+pub use parking_lot::{Mutex, MutexGuard};
+//pub use crate::debugmutex::{Mutex, MutexGuard};
+
+pub use crate::support::*;
+pub use crate::tz::*;
+
diff --git a/support/prelude.rs b/support/prelude.rs
new file mode 100644 (file)
index 0000000..2aa0399
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2020-2021 Ian Jackson and contributors to Otter
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+pub use crate::imports::*;
+pub use crate::prelude_part::*;
+
+pub use otter_base::imports::*;
+pub use otter_base::prelude_part::*;
+
diff --git a/support/support.rs b/support/support.rs
new file mode 100644 (file)
index 0000000..3296df0
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright 2020-2021 Ian Jackson and contributors to Otter
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+use crate::prelude::*;
+
+#[derive(Copy,Clone,Debug,Serialize,Deserialize,Eq,Ord,PartialEq,PartialOrd)]
+#[serde(transparent)]
+pub struct Timestamp(pub u64); /* time_t */
+
+impl Timestamp {
+  /// Always >= previously
+  pub fn now() -> Timestamp {
+    use std::time::SystemTime;
+    let now = SystemTime::now()
+      .duration_since(SystemTime::UNIX_EPOCH)
+      .unwrap()
+      .as_secs();
+    Timestamp(now)
+  }
+
+  pub fn render(&self, tz: &Timezone) -> String {
+    tz.format(*self)
+  }
+}
+
+