From 95880f82889bb0a9f87e007e8d2287b207a62bcb Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 12 May 2021 00:41:40 +0100 Subject: [PATCH] progress: Break out into nascent module Signed-off-by: Ian Jackson --- src/bundles.rs | 5 ++--- src/commands.rs | 6 ------ src/lib.rs | 1 + src/packetframe.rs | 1 - src/prelude.rs | 1 + src/progress.rs | 21 +++++++++++++++++++++ 6 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 src/progress.rs diff --git a/src/bundles.rs b/src/bundles.rs index cc07d59d..efdbecc2 100644 --- a/src/bundles.rs +++ b/src/bundles.rs @@ -437,9 +437,8 @@ where EH: BundleParseErrorHandling, } #[throws(LE)] -fn process_bundle(id: Id, instance: &InstanceName, - _for_progress: &ResponseWriter) -where W: Write +fn process_bundle(id: Id, instance: &InstanceName, + _for_progress: &dyn ProgressReporter) { let dir = id.path_dir(instance); fs::create_dir(&dir) diff --git a/src/commands.rs b/src/commands.rs index b17cafdc..b618ac26 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -134,12 +134,6 @@ pub enum MgmtGameInstruction { // RemovePlayer { player: PlayerId }, todo, does a special setacl } -#[derive(Debug,Clone,Serialize,Deserialize)] -pub struct ProgressInfo { - count: usize, - of: usize, -} - #[derive(Debug,Serialize,Deserialize)] pub struct MgmtPlayerDetails { pub nick: Option, diff --git a/src/lib.rs b/src/lib.rs index 64ac7e94..4da24030 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,6 +32,7 @@ pub mod packetframe; pub mod pcaliases; pub mod pcrender; pub mod pieces; +pub mod progress; pub mod shapelib; pub mod spec; pub mod sse; diff --git a/src/packetframe.rs b/src/packetframe.rs index 48b6b7ac..c31cf98e 100644 --- a/src/packetframe.rs +++ b/src/packetframe.rs @@ -14,7 +14,6 @@ //! 0xffffu16 marker, error! use crate::prelude::*; -use crate::commands::ProgressInfo; // ---------- common ---------- diff --git a/src/prelude.rs b/src/prelude.rs index 221062a3..69accabc 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -149,6 +149,7 @@ pub use crate::packetframe::{ReadExt}; pub use crate::pcaliases::*; pub use crate::pcrender::*; pub use crate::pieces::*; +pub use crate::progress::*; pub use crate::shapelib; pub use crate::shapelib::{CircleShape, RectShape}; pub use crate::slotmap_slot_idx::*; diff --git a/src/progress.rs b/src/progress.rs new file mode 100644 index 00000000..30544869 --- /dev/null +++ b/src/progress.rs @@ -0,0 +1,21 @@ +// Copyright 2020-2021 Ian Jackson and contributors to Otter +// SPDX-License-Identifier: AGPL-3.0-or-later +// There is NO WARRANTY. + +use crate::prelude::*; +use crate::packetframe::ResponseWriter; + +#[derive(Debug,Clone,Serialize,Deserialize)] +pub struct ProgressInfo { + pub count: usize, + pub of: usize, +} + +pub trait ProgressReporter { +} + +impl ProgressReporter for ResponseWriter<'_, W> where W: Write { +} + +impl ProgressReporter for () { +} -- 2.30.2