"base64 0.13.0",
"boolinator",
"bundle-sources",
- "byteorder",
"cast_trait_object",
- "console",
"const-default",
"crossbeam-utils",
"delegate",
- "derive-into-owned",
"digest 0.10.3",
"downcast-rs",
"educe",
"libc",
"mio 0.8.2",
"num",
- "num-derive",
"num-traits",
"once_cell",
"openssh-keys",
"pwd",
"rand 0.8.5",
"regex",
- "rmp",
- "rmp-serde",
"serde",
"serde_with",
"sha2 0.10.2",
"typetag",
"uds",
"unicase",
- "unicode-width",
"url",
"usvg",
"vecdeque-stableix",
version = "1.0.0"
dependencies = [
"anyhow",
+ "byteorder",
"chrono",
"chrono-tz",
+ "console",
+ "derive-into-owned",
"fehler",
"log",
"nix 0.23.1",
+ "num-derive",
+ "num-traits",
"otter-base",
"parking_lot",
+ "rmp",
+ "rmp-serde",
"serde",
"serde_with",
+ "strum",
+ "unicode-width",
]
[[package]]
backtrace="0.3"
base64="0.13"
boolinator="2"
-byteorder="1.3"
cast_trait_object="0.1"
-console="0.15"
crossbeam-utils="0.8"
delegate="0.6"
-derive-into-owned="0.2"
digest="0.10"
downcast-rs="1"
educe="0.4"
lazy_static="1"
libc="0.2"
num="0.4"
-num-derive="0.3"
-num-traits="0.2"
once_cell="1"
openssh-keys="0.5"
ordered-float="2"
pwd="1"
rand="0.8"
regex="1"
-rmp="0.8"
-rmp-serde="1"
structopt="0.3"
sha2="0.10"
subtle="2.4"
typetag="0.1.6"
uds="0.2"
unicase="2"
-unicode-width="0.1"
url="2"
vecdeque-stableix="1"
xmlparser = "0.13"
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" ] }
-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"] }
+num-traits="0.2"
serde_with="1"
thiserror="1"
+serde = { version="1" , features=["derive", "rc"] }
+strum = { version="0.24" , features=["derive" ] }
#fin.
// management API implementation
use otter::crates::*;
+use otter_support::imports::*;
use super::*;
use otter::commands::*;
{
let mut for_progress_box: Box<dyn progress::Originator> =
if progress_mode >= PUM::Simplex {
- Box::new(progress::ResponseOriginator::new(progress_stream))
+ Box::new(progress::ResponseOriginator::new(
+ progress_stream,
+ |pi: ProgressInfo<'_>| MgmtResponse::Progress(pi.into_owned()),
+ ))
} else {
Box::new(())
};
pub use ordered_float;
pub use pwd;
pub use regex;
-pub use rmp_serde;
pub use sha2;
pub use slotmap;
pub use tera;
pub use toml;
pub use uds;
-pub use unicode_width;
pub use vecdeque_stableix;
pub use zip as zipfile;
use otter_base::imports::*;
pub use std::any::Any;
-pub use std::borrow::Cow;
-pub use std::cmp::{self, max, min, Ordering};
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 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 lazy_regex::regex;
pub use lazy_static::lazy_static;
pub use log::{log, log_enabled};
-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 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 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::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::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 mod nwtemplates;
pub mod occultilks;
pub mod organise;
-pub mod packetframe;
pub mod pcaliases;
pub mod pcrender;
pub mod pieces;
-pub mod progress;
pub mod shapelib;
pub mod spec;
-pub mod termprogress;
pub mod timedfd;
pub mod updates;
pub mod ui;
use crate::prelude::*;
use crate::commands::*;
-#[derive(Debug,Error)]
-pub enum MgmtChannelReadError {
- #[error("unexpected EOF")] EOF,
- #[error("parse MessagePack: {0}")] Parse(String),
- #[error("{0}")] IO(#[from] io::Error),
-}
-
-#[derive(Debug,Error)]
-pub enum MgmtChannelWriteError {
- Serialize(rmp_serde::encode::Error), // but not ValueWriteError so no from
- IO(#[from] io::Error),
-}
-display_as_debug!{MgmtChannelWriteError}
-
-impl From<rmp_serde::encode::Error> for MgmtChannelWriteError {
- fn from(re: rmp_serde::encode::Error) -> MgmtChannelWriteError {
- use rmp_serde::encode::Error::*;
- use MgmtChannelWriteError as MCWE;
- use rmp::encode::ValueWriteError as RVWE;
- match re {
- InvalidValueWrite(RVWE::InvalidMarkerWrite(ioe)) => MCWE::IO(ioe),
- InvalidValueWrite(RVWE::InvalidDataWrite (ioe)) => MCWE::IO(ioe),
- ser@ (UnknownLength | InvalidDataModel(_) |
- DepthLimitExceeded | Syntax(_)) => MCWE::Serialize(ser),
- }
- }
-}
-
pub struct MgmtChannel<R:Read, W:Write> {
pub read: FrameReader<R>,
pub write: FrameWriter<W>,
assert_eq!( parse_fixed_hex("xy" ), None::<[_;1]> );
}
-//========== matches_doesnot ==========
-
-#[macro_export] // <- otherwise bogus warning `unused_macros`
-macro_rules! matches_doesnot_yn2bool {
- (=) => (true);
- (!) => (false);
-}
-
-#[macro_export]
-macro_rules! matches_doesnot {
- ($v:expr,
- $(
- $yn:tt $p:pat
- ),* $(,)?
- ) => {
- match $v {
- $(
- $p => $crate::matches_doesnot_yn2bool!($yn),
- )*
- }
- }
-}
-
-#[test]
-fn matches_doesnot_test() {
- assert!(
- matches_doesnot!(
- Some(42),
- = Some(_),
- ! None
- )
- );
- assert!(
- matches_doesnot!(
- Some(42),
- ! None,
- ! Some(3),
- = Some(_),
- )
- );
- assert!(
- matches_doesnot!(
- Some(1),
- = Some(1) | Some(2),
- ! Some(_) | None
- )
- );
- assert!(
- ! matches_doesnot!(
- Some(1),
- ! Some(1) | Some(2),
- = Some(_) | None
- )
- );
-}
-
//========== want* macros ==========
#[macro_export]
otter-base.version="=1.0.0"
anyhow="1"
+byteorder="1.3"
chrono="0.4"
chrono-tz="0.6"
+console="0.15"
+derive-into-owned="0.2"
fehler="1"
log="0.4"
nix="0.23"
+num-derive="0.3"
parking_lot="0.12"
+rmp="0.8"
+rmp-serde="1"
+unicode-width="0.1"
+# Repeated in other Cargo.toml's because importing does not work properly
+num-traits="0.2"
serde_with="1"
-
serde = { version="1" , features=["derive", "rc"] }
+strum = { version="0.24" , features=["derive" ] }
#fin.
pub use log;
pub use nix;
pub use parking_lot;
+pub use rmp_serde;
+pub use unicode_width;
// See Import Structure Doctrine in src/prelude.rs
+pub use std::borrow::Cow;
+pub use std::cmp::{self, max, min, Ordering};
pub use std::collections::{hash_map, HashMap, HashSet};
pub use std::collections::VecDeque;
pub use std::collections::{btree_map, BTreeMap};
pub use std::collections::{btree_set, BTreeSet};
+pub use std::env;
pub use std::fs;
pub use std::fs::File;
pub use std::io;
pub use std::sync::Arc;
pub use anyhow::{anyhow, ensure, Context};
+pub use byteorder::{BigEndian, LittleEndian, ReadBytesExt, WriteBytesExt};
+pub use derive_into_owned::IntoOwned;
pub use log::{debug, error, info, trace, warn};
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 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 strum::{EnumCount, EnumDiscriminants};
+pub use strum::{EnumString, EnumIter, EnumMessage, EnumProperty};
+pub use strum::{AsRefStr, IntoEnumIterator, IntoStaticStr};
// No debug version of this
pub use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
pub use parking_lot::{Mutex, MutexGuard};
//pub use crate::debugmutex::{Mutex, MutexGuard};
+pub use crate::matches_doesnot;
+
pub use crate::childio;
pub use crate::debugmutex::DebugIdentify;
+pub use crate::packetframe::{FrameReader, FrameWriter, ReadFrame, WriteFrame};
+pub use crate::packetframe::{ReadExt, ResponseWriter};
+pub use crate::packetframe::{MgmtChannelReadError, MgmtChannelWriteError};
+pub use crate::progress::{self, ProgressInfo, OriginatorExt as _};
pub use crate::support::*;
+pub use crate::termprogress;
pub use crate::tz::*;
// ---------- type abbreviations ----------
pub mod childio;
pub mod debugmutex;
+pub mod packetframe;
+pub mod progress;
pub mod support;
+pub mod termprogress;
pub mod tz;
use crate::prelude::*;
+// ---------- errors (MgmtChannel, anomalous name) ----------
+
+#[derive(Debug,Error)]
+pub enum MgmtChannelReadError {
+ #[error("unexpected EOF")] EOF,
+ #[error("parse MessagePack: {0}")] Parse(String),
+ #[error("{0}")] IO(#[from] io::Error),
+}
+
+#[derive(Debug,Error)]
+pub enum MgmtChannelWriteError {
+ Serialize(rmp_serde::encode::Error), // but not ValueWriteError so no from
+ IO(#[from] io::Error),
+}
+display_as_debug!{MgmtChannelWriteError}
+
+impl From<rmp_serde::encode::Error> for MgmtChannelWriteError {
+ fn from(re: rmp_serde::encode::Error) -> MgmtChannelWriteError {
+ use rmp_serde::encode::Error::*;
+ use MgmtChannelWriteError as MCWE;
+ use rmp::encode::ValueWriteError as RVWE;
+ match re {
+ InvalidValueWrite(RVWE::InvalidMarkerWrite(ioe)) => MCWE::IO(ioe),
+ InvalidValueWrite(RVWE::InvalidDataWrite (ioe)) => MCWE::IO(ioe),
+ ser@ (UnknownLength | InvalidDataModel(_) |
+ DepthLimitExceeded | Syntax(_)) => MCWE::Serialize(ser),
+ }
+ }
+}
+
// ---------- common ----------
type ChunkLen = u16;
self.f
}
-
+ #[throws(MgmtChannelWriteError)]
+ pub fn progress_with<RESP: Serialize>(&mut self, resp: RESP) {
+ rmp_serde::encode::write_named(&mut self.f, &resp)?;
+ self.f.flush()?;
+ }
+/*
#[throws(MgmtChannelWriteError)]
pub fn progress(&mut self, pi: ProgressInfo<'_>) {
let resp = crate::commands::MgmtResponse::Progress(pi.into_owned());
rmp_serde::encode::write_named(&mut self.f, &resp)?;
self.f.flush()?;
- }
+ }*/
}
// ==================== tests ====================
fn item_(&mut self, item: usize, desc: Cow<'_, str>);
}
-pub struct ResponseOriginator<'c,'w,W> where W: Write {
+pub struct ResponseOriginator<'c,'w,W,F> where W: Write {
chan: &'c mut ResponseWriter<'w,W>,
phase: Count<'static>,
len: usize,
+ formatter: F,
}
-impl<'c,'w,W> ResponseOriginator<'c,'w,W> where W: Write {
- pub fn new(chan: &'c mut ResponseWriter<'w,W>) -> Self { Self {
+impl<'c,'w,W,F> ResponseOriginator<'c,'w,W,F> where W: Write {
+ pub fn new(chan: &'c mut ResponseWriter<'w,W>,
+ formatter: F) -> Self { Self {
chan,
phase: Count { i:0, n:0, desc: Cow::Borrowed("") },
len: 0,
+ formatter,
} }
}
-impl<W> Originator for ResponseOriginator<'_,'_,W> where W: Write {
+impl<W,F,M> Originator for ResponseOriginator<'_,'_,W,F>
+where W: Write,
+ F: Fn(ProgressInfo<'_>) -> M,
+ M: Serialize,
+{
fn report(&mut self, pi: ProgressInfo<'_>) {
- self.chan.progress(pi).unwrap_or(());
+ let resp = (self.formatter)(pi);
+ self.chan.progress_with(resp).unwrap_or(());
}
fn phase_begin_(&mut self, phase: Count<'_>, len: usize) {
self.phase = phase.into_owned();
use crate::prelude::*;
+//========== Timestamp ==========
+
#[derive(Copy,Clone,Debug,Serialize,Deserialize,Eq,Ord,PartialEq,PartialOrd)]
#[serde(transparent)]
pub struct Timestamp(pub u64); /* time_t */
}
}
+//========== matches_doesnot ==========
+
+#[macro_export] // <- otherwise bogus warning `unused_macros`
+macro_rules! matches_doesnot_yn2bool {
+ (=) => (true);
+ (!) => (false);
+}
+
+#[macro_export]
+macro_rules! matches_doesnot {
+ ($v:expr,
+ $(
+ $yn:tt $p:pat
+ ),* $(,)?
+ ) => {
+ match $v {
+ $(
+ $p => $crate::matches_doesnot_yn2bool!($yn),
+ )*
+ }
+ }
+}
+
+#[test]
+fn matches_doesnot_test() {
+ assert!(
+ matches_doesnot!(
+ Some(42),
+ = Some(_),
+ ! None
+ )
+ );
+ assert!(
+ matches_doesnot!(
+ Some(42),
+ ! None,
+ ! Some(3),
+ = Some(_),
+ )
+ );
+ assert!(
+ matches_doesnot!(
+ Some(1),
+ = Some(1) | Some(2),
+ ! Some(_) | None
+ )
+ );
+ assert!(
+ ! matches_doesnot!(
+ Some(1),
+ ! Some(1) | Some(2),
+ = Some(_) | None
+ )
+ );
+}