From 6e9762c58429b97e859c37faddff5504733d2a5f Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Tue, 1 Oct 2024 09:02:39 -0700 Subject: [PATCH] bump dropshot and friends (#109) Signed-off-by: Jess Frazelle --- Cargo.lock | 27 +++++++++++++------------ Cargo.toml | 12 +++++------ src/any_machine.rs | 3 ++- src/bambu/control.rs | 5 +++-- src/bambu/discover.rs | 10 +++++---- src/bambu/mod.rs | 5 +++-- src/bin/machine-api/cmd_serve.rs | 6 ++++-- src/bin/machine-api/config/bambu.rs | 6 ++++-- src/bin/machine-api/config/mod.rs | 3 ++- src/bin/machine-api/config/moonraker.rs | 6 ++++-- src/bin/machine-api/config/noop.rs | 6 ++++-- src/bin/machine-api/config/usb.rs | 6 ++++-- src/discover.rs | 4 +++- src/file.rs | 3 ++- src/gcode/mod.rs | 3 ++- src/lib.rs | 8 ++++---- src/machine.rs | 3 ++- src/moonraker/control.rs | 8 +++++--- src/moonraker/mod.rs | 6 +++--- src/moonraker/variants.rs | 3 ++- src/noop.rs | 3 ++- src/server/context.rs | 4 +++- src/server/cors.rs | 3 +-- src/server/endpoints.rs | 3 ++- src/server/mod.rs | 6 +++--- src/slicer/config.rs | 6 ++++-- src/slicer/mod.rs | 5 +++-- src/slicer/noop.rs | 3 ++- src/slicer/orca.rs | 3 ++- src/slicer/prusa.rs | 3 ++- src/sync.rs | 4 +++- src/tests.rs | 7 ++++--- src/traits.rs | 6 ++++-- src/usb/control.rs | 13 ++++++------ src/usb/discover.rs | 8 +++++--- src/usb/discover_variants.rs | 3 ++- 36 files changed, 128 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 87bce9c..c7510fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -613,9 +613,9 @@ dependencies = [ [[package]] name = "dropshot" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c6e9b34bd648388057b52a325b82bbe2ee051f8c2450b04e6dc958437f7bb3f" +checksum = "ab804b8d4ab58d96e1e19c8ef87e1747a70d2819e92b659d6fe8d5ac5ac44d50" dependencies = [ "async-stream", "async-trait", @@ -624,12 +624,14 @@ dependencies = [ "camino", "chrono", "debug-ignore", - "dropshot_endpoint 0.11.0", + "dropshot_endpoint 0.12.0", "form_urlencoded", "futures", "hostname 0.4.0", - "http 0.2.12", - "hyper 0.14.30", + "http 1.1.0", + "http-body-util", + "hyper 1.4.1", + "hyper-util", "indexmap 2.5.0", "multer", "openapiv3", @@ -672,9 +674,9 @@ dependencies = [ [[package]] name = "dropshot_endpoint" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f3c60e1db003f3bf870ab51a38de22ab3331cc0c06ede90b0542db0c554885" +checksum = "796be76b11b79de0decd7be2105add01220f8bbe04cf1f83214c0b801414a722" dependencies = [ "heck", "proc-macro2", @@ -1204,9 +1206,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", @@ -1217,7 +1219,6 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", "tower-service", "tracing", ] @@ -1447,12 +1448,12 @@ dependencies = [ "console-subscriber", "dashmap", "delouse", - "dropshot 0.11.0", + "dropshot 0.12.0", "expectorate", "futures", "futures-util", - "http 0.2.12", - "hyper 0.14.30", + "http 1.1.0", + "hyper 1.4.1", "libmdns", "moonraker", "multer", diff --git a/Cargo.toml b/Cargo.toml index 2e673b9..8640d9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,12 +30,14 @@ clap = { version = "4.5.18", features = ["cargo", "derive", "env", "unicode"] } console-subscriber = { version = "0", optional = true } dashmap = "6.1.0" delouse = { version = "0.1", optional = true } -dropshot = "0.11" +dropshot = "0.12" futures = "0.3.28" futures-util = "0.3.30" +http = "1" +hyper = "1" libmdns = "0.9.1" -multer = { version = "3.1.0", features = ["json"] } moonraker = { path = "moonraker", optional = true } +multer = { version = "3.1.0", features = ["json"] } opentelemetry = "0.24.0" opentelemetry-otlp = "0.17.0" opentelemetry_sdk = { version = "0.24.1", features = ["rt-tokio"] } @@ -50,15 +52,13 @@ slog-json = "2.6.1" slog-term = "2.9.1" thiserror = "1.0.64" tokio = { version = "1", features = ["rt-multi-thread", "macros", "time", "net"] } +tokio-serial = { version = "5", optional = true, features = ["tokio-util", "libudev"] } toml = "0.8.19" tracing = "0.1" tracing-opentelemetry = "0.25.0" +tracing-slog = "0.3.0" tracing-subscriber = { version = "0.3.18", features = ["registry", "std", "fmt", "smallvec", "ansi", "tracing-log", "json", "env-filter"] } uuid = "1.10.0" -tokio-serial = { version = "5", optional = true, features = ["tokio-util", "libudev"] } -tracing-slog = "0.3.0" -http = "0.2.9" -hyper = "0.14" [dev-dependencies] async-trait = "0.1" diff --git a/src/any_machine.rs b/src/any_machine.rs index 3161096..f84a7b0 100644 --- a/src/any_machine.rs +++ b/src/any_machine.rs @@ -1,6 +1,7 @@ -use crate::{Control as ControlTrait, MachineInfo, MachineMakeModel, MachineType, Volume}; use anyhow::Result; +use crate::{Control as ControlTrait, MachineInfo, MachineMakeModel, MachineType, Volume}; + /// AnyMachine is any supported machine. #[non_exhaustive] pub enum AnyMachine { diff --git a/src/bambu/control.rs b/src/bambu/control.rs index 1a06cb0..25f6507 100644 --- a/src/bambu/control.rs +++ b/src/bambu/control.rs @@ -1,10 +1,11 @@ +use anyhow::Result; +use bambulabs::{client::Client, command::Command}; + use super::{PrinterInfo, X1Carbon}; use crate::{ Control as ControlTrait, MachineInfo as MachineInfoTrait, MachineMakeModel, MachineType, SuspendControl as SuspendControlTrait, ThreeMfControl as ThreeMfControlTrait, ThreeMfTemporaryFile, Volume, }; -use anyhow::Result; -use bambulabs::{client::Client, command::Command}; impl X1Carbon { /// Return a borrow of the underlying Client. diff --git a/src/bambu/discover.rs b/src/bambu/discover.rs index 533f7e6..14b6381 100644 --- a/src/bambu/discover.rs +++ b/src/bambu/discover.rs @@ -1,14 +1,16 @@ -use super::{PrinterInfo, X1Carbon}; -use crate::{slicer, Discover as DiscoverTrait, Machine, MachineMakeModel}; -use anyhow::Result; -use serde::{Deserialize, Serialize}; use std::{ collections::HashMap, net::{IpAddr, Ipv4Addr}, sync::Arc, }; + +use anyhow::Result; +use serde::{Deserialize, Serialize}; use tokio::{net::UdpSocket, sync::RwLock}; +use super::{PrinterInfo, X1Carbon}; +use crate::{slicer, Discover as DiscoverTrait, Machine, MachineMakeModel}; + /// Specific make/model of Bambu device. #[derive(Copy, Clone, Debug, Deserialize, Serialize)] #[non_exhaustive] diff --git a/src/bambu/mod.rs b/src/bambu/mod.rs index 6ef83dd..6c70c0c 100644 --- a/src/bambu/mod.rs +++ b/src/bambu/mod.rs @@ -3,11 +3,12 @@ mod control; mod discover; +use std::{net::IpAddr, sync::Arc}; + +use bambulabs::client::Client; pub use discover::{BambuVariant, Config, X1CarbonDiscover}; use crate::MachineMakeModel; -use bambulabs::client::Client; -use std::{net::IpAddr, sync::Arc}; /// Control channel handle to a Bambu Labs X1 Carbon. #[derive(Clone)] diff --git a/src/bin/machine-api/cmd_serve.rs b/src/bin/machine-api/cmd_serve.rs index 47a7151..75030ce 100644 --- a/src/bin/machine-api/cmd_serve.rs +++ b/src/bin/machine-api/cmd_serve.rs @@ -1,9 +1,11 @@ -use super::{Cli, Config}; +use std::{collections::HashMap, net::SocketAddr, sync::Arc}; + use anyhow::Result; use machine_api::server; -use std::{collections::HashMap, net::SocketAddr, sync::Arc}; use tokio::sync::RwLock; +use super::{Cli, Config}; + pub async fn main(_cli: &Cli, cfg: &Config, bind: &str) -> Result<()> { let machines = Arc::new(RwLock::new(HashMap::new())); diff --git a/src/bin/machine-api/config/bambu.rs b/src/bin/machine-api/config/bambu.rs index df29617..72495bf 100644 --- a/src/bin/machine-api/config/bambu.rs +++ b/src/bin/machine-api/config/bambu.rs @@ -1,9 +1,11 @@ -use super::{Config, MachineConfig}; +use std::{collections::HashMap, sync::Arc}; + use anyhow::Result; use machine_api::{bambu, Discover, Machine}; -use std::{collections::HashMap, sync::Arc}; use tokio::sync::RwLock; +use super::{Config, MachineConfig}; + impl Config { pub async fn spawn_discover_bambu(&self, machines: Arc>>>) -> Result<()> { let discovery = bambu::X1CarbonDiscover::new( diff --git a/src/bin/machine-api/config/mod.rs b/src/bin/machine-api/config/mod.rs index 92678c0..8e34be0 100644 --- a/src/bin/machine-api/config/mod.rs +++ b/src/bin/machine-api/config/mod.rs @@ -1,6 +1,7 @@ +use std::collections::HashMap; + use machine_api::{bambu as crate_bambu, moonraker as crate_moonraker, usb as crate_usb}; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; mod bambu; mod moonraker; diff --git a/src/bin/machine-api/config/moonraker.rs b/src/bin/machine-api/config/moonraker.rs index 72538e6..cccf64e 100644 --- a/src/bin/machine-api/config/moonraker.rs +++ b/src/bin/machine-api/config/moonraker.rs @@ -1,9 +1,11 @@ -use super::{Config, MachineConfig}; +use std::{collections::HashMap, sync::Arc}; + use anyhow::Result; use machine_api::{moonraker, Machine, MachineMakeModel}; -use std::{collections::HashMap, sync::Arc}; use tokio::sync::RwLock; +use super::{Config, MachineConfig}; + impl Config { pub async fn create_moonraker(&self, machines: Arc>>>) -> Result<()> { for (key, config) in self diff --git a/src/bin/machine-api/config/noop.rs b/src/bin/machine-api/config/noop.rs index d6d535e..2729a68 100644 --- a/src/bin/machine-api/config/noop.rs +++ b/src/bin/machine-api/config/noop.rs @@ -1,9 +1,11 @@ -use super::{Config, MachineConfig}; +use std::{collections::HashMap, sync::Arc}; + use anyhow::Result; use machine_api::{noop, slicer, Machine, MachineMakeModel, MachineType, Volume}; -use std::{collections::HashMap, sync::Arc}; use tokio::sync::RwLock; +use super::{Config, MachineConfig}; + impl Config { pub async fn create_noop(&self, machines: Arc>>>) -> Result<()> { for (key, _config) in self diff --git a/src/bin/machine-api/config/usb.rs b/src/bin/machine-api/config/usb.rs index 67e4150..6351242 100644 --- a/src/bin/machine-api/config/usb.rs +++ b/src/bin/machine-api/config/usb.rs @@ -1,9 +1,11 @@ -use super::{Config, MachineConfig}; +use std::{collections::HashMap, sync::Arc}; + use anyhow::Result; use machine_api::{usb, Discover, Machine}; -use std::{collections::HashMap, sync::Arc}; use tokio::sync::RwLock; +use super::{Config, MachineConfig}; + impl Config { pub async fn spawn_discover_usb(&self, machines: Arc>>>) -> Result<()> { let discovery = usb::UsbDiscovery::new( diff --git a/src/discover.rs b/src/discover.rs index 08978a7..de3c72e 100644 --- a/src/discover.rs +++ b/src/discover.rs @@ -1,7 +1,9 @@ -use crate::Machine; use std::{collections::HashMap, future::Future, sync::Arc}; + use tokio::sync::RwLock; +use crate::Machine; + /// Discover trait implemented by backends in order to add or remove /// configured machines. pub trait Discover { diff --git a/src/file.rs b/src/file.rs index e587b8d..440fe12 100644 --- a/src/file.rs +++ b/src/file.rs @@ -1,5 +1,6 @@ -use anyhow::Result; use std::path::{Path, PathBuf}; + +use anyhow::Result; use tokio::fs::File; /// A TemporaryFile wraps a normal [tokio::fs::File]`, but will attempt to diff --git a/src/gcode/mod.rs b/src/gcode/mod.rs index 4e18c66..73b513a 100644 --- a/src/gcode/mod.rs +++ b/src/gcode/mod.rs @@ -1,11 +1,12 @@ //! This module contains support for printing to gcode based 3D printers //! over some [AsyncRead]/[AsyncWrite] traited object. -use anyhow::Result; use std::{ pin::Pin, task::{Context as TaskContext, Poll}, }; + +use anyhow::Result; use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, BufReader, ReadBuf}; /// Create a handle to some [tokio::io::AsyncWrite] diff --git a/src/lib.rs b/src/lib.rs index 6cd6c4b..c1e8af7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,10 +32,14 @@ mod traits; #[cfg(feature = "serial")] pub mod usb; +use std::path::PathBuf; + pub use any_machine::{AnyMachine, AnyMachineInfo}; pub use discover::Discover; pub use file::TemporaryFile; pub use machine::Machine; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; pub use slicer::AnySlicer; pub use sync::SharedMachine; pub use traits::{ @@ -43,10 +47,6 @@ pub use traits::{ ThreeMfControl, ThreeMfSlicer, ThreeMfTemporaryFile, }; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use std::path::PathBuf; - /// A specific file containing a design to be manufactured. #[non_exhaustive] pub enum DesignFile { diff --git a/src/machine.rs b/src/machine.rs index 3c1f437..fcdedb3 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -1,6 +1,7 @@ -use crate::{AnyMachine, AnySlicer, DesignFile, GcodeControl, GcodeSlicer, ThreeMfControl, ThreeMfSlicer}; use anyhow::Result; +use crate::{AnyMachine, AnySlicer, DesignFile, GcodeControl, GcodeSlicer, ThreeMfControl, ThreeMfSlicer}; + /// Create a handle to a specific Machine which is capable of producing a 3D /// object in the real world from a specific [crate::DesignFile]. pub struct Machine { diff --git a/src/moonraker/control.rs b/src/moonraker/control.rs index 5e03db7..4f1e768 100644 --- a/src/moonraker/control.rs +++ b/src/moonraker/control.rs @@ -1,11 +1,13 @@ +use std::path::PathBuf; + +use anyhow::Result; +use moonraker::InfoResponse; + use super::Client; use crate::{ Control as ControlTrait, GcodeControl as GcodeControlTrait, GcodeTemporaryFile, MachineInfo as MachineInfoTrait, MachineMakeModel, MachineType, SuspendControl as SuspendControlTrait, Volume, }; -use anyhow::Result; -use moonraker::InfoResponse; -use std::path::PathBuf; /// Information about the connected Moonraker-based printer. #[derive(Debug, Clone, PartialEq)] diff --git a/src/moonraker/mod.rs b/src/moonraker/mod.rs index 6aea905..4f2ad9e 100644 --- a/src/moonraker/mod.rs +++ b/src/moonraker/mod.rs @@ -3,13 +3,13 @@ mod control; mod variants; +use anyhow::Result; pub use control::MachineInfo; +use moonraker::Client as MoonrakerClient; +use serde::{Deserialize, Serialize}; pub use variants::MoonrakerVariant; use crate::{slicer, MachineMakeModel, Volume}; -use anyhow::Result; -use moonraker::Client as MoonrakerClient; -use serde::{Deserialize, Serialize}; /// Configuration information for a Moonraker-based endpoint. #[derive(Clone, Debug, Serialize, Deserialize)] diff --git a/src/moonraker/variants.rs b/src/moonraker/variants.rs index 5ae2f66..d88553f 100644 --- a/src/moonraker/variants.rs +++ b/src/moonraker/variants.rs @@ -1,6 +1,7 @@ -use crate::{MachineType, Volume}; use serde::{Deserialize, Serialize}; +use crate::{MachineType, Volume}; + macro_rules! moonraker_devices { ($( $name:ident( diff --git a/src/noop.rs b/src/noop.rs index 98d57e5..02f805b 100644 --- a/src/noop.rs +++ b/src/noop.rs @@ -1,12 +1,13 @@ //! `noop` implements a no-op Machine, one that will accept Control commands //! and do exactly nothing with it. +use anyhow::Result; + use crate::{ Control as ControlTrait, GcodeControl as GcodeControlTrait, GcodeTemporaryFile, MachineInfo as MachineInfoTrait, MachineMakeModel, MachineType, SuspendControl as SuspendControlTrait, ThreeMfControl as ThreeMfControlTrait, ThreeMfTemporaryFile, Volume, }; -use anyhow::Result; /// Noop-machine will no-op, well, everything. pub struct Noop { diff --git a/src/server/context.rs b/src/server/context.rs index 69df15d..1b6533d 100644 --- a/src/server/context.rs +++ b/src/server/context.rs @@ -1,7 +1,9 @@ -use crate::Machine; use std::{collections::HashMap, sync::Arc}; + use tokio::sync::RwLock; +use crate::Machine; + /// Context for a given server -- this contains all the informatio required /// to serve a Machine-API request. pub struct Context { diff --git a/src/server/cors.rs b/src/server/cors.rs index 807b7f6..d73a4f9 100644 --- a/src/server/cors.rs +++ b/src/server/cors.rs @@ -1,6 +1,5 @@ -use dropshot::{HttpCodedResponse, HttpError}; +use dropshot::{Body, HttpCodedResponse, HttpError}; use http::{Response, StatusCode}; -use hyper::Body; use schemars::JsonSchema; use serde::Serialize; diff --git a/src/server/endpoints.rs b/src/server/endpoints.rs index 834230c..006f827 100644 --- a/src/server/endpoints.rs +++ b/src/server/endpoints.rs @@ -1,7 +1,8 @@ +use std::sync::Arc; + use dropshot::{endpoint, HttpError, Path, RequestContext}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use std::sync::Arc; use super::{Context, CorsResponseOk}; use crate::{AnyMachine, Control, DesignFile, MachineInfo, MachineMakeModel, MachineType, TemporaryFile, Volume}; diff --git a/src/server/mod.rs b/src/server/mod.rs index 654db08..b9cc32d 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -4,16 +4,16 @@ mod context; mod cors; mod endpoints; -pub use context::Context; -pub use cors::CorsResponseOk; +use std::{collections::HashMap, env, net::SocketAddr, sync::Arc}; use anyhow::{anyhow, Result}; +pub use context::Context; +pub use cors::CorsResponseOk; use dropshot::{ApiDescription, ConfigDropshot, HttpServerStarter}; use signal_hook::{ consts::{SIGINT, SIGTERM}, iterator::Signals, }; -use std::{collections::HashMap, env, net::SocketAddr, sync::Arc}; use tokio::sync::RwLock; use crate::Machine; diff --git a/src/slicer/config.rs b/src/slicer/config.rs index daa7cc9..7431305 100644 --- a/src/slicer/config.rs +++ b/src/slicer/config.rs @@ -1,7 +1,9 @@ -use super::{orca, prusa, AnySlicer}; +use std::path::PathBuf; + use anyhow::Result; use serde::{Deserialize, Serialize}; -use std::path::PathBuf; + +use super::{orca, prusa, AnySlicer}; /// Standard slicer config -- as used by the machine-api server and any /// other consumers. diff --git a/src/slicer/mod.rs b/src/slicer/mod.rs index 6867a07..d2d006f 100644 --- a/src/slicer/mod.rs +++ b/src/slicer/mod.rs @@ -7,12 +7,13 @@ pub mod noop; pub mod orca; pub mod prusa; +use anyhow::Result; +pub use config::Config; + use crate::{ DesignFile, GcodeSlicer as GcodeSlicerTrait, GcodeTemporaryFile, ThreeMfSlicer as ThreeMfSlicerTrait, ThreeMfTemporaryFile, }; -use anyhow::Result; -pub use config::Config; /// All Slicers that are supported by the machine-api. #[non_exhaustive] diff --git a/src/slicer/noop.rs b/src/slicer/noop.rs index aaf04dd..ef35785 100644 --- a/src/slicer/noop.rs +++ b/src/slicer/noop.rs @@ -1,11 +1,12 @@ //! `noop` implements a no-op Machine, one that will accept Control commands //! and do exactly nothing with it. +use anyhow::Result; + use crate::{ DesignFile, GcodeSlicer as GcodeSlicerTrait, GcodeTemporaryFile, TemporaryFile, ThreeMfSlicer as ThreeMfSlicerTrait, ThreeMfTemporaryFile, }; -use anyhow::Result; /// Noop-slicer won't slice anything at all! #[derive(Copy, Clone, Debug)] diff --git a/src/slicer/orca.rs b/src/slicer/orca.rs index c43e66c..291e520 100644 --- a/src/slicer/orca.rs +++ b/src/slicer/orca.rs @@ -1,7 +1,8 @@ //! Support for the orca Slicer. -use anyhow::{Context, Result}; use std::path::{Path, PathBuf}; + +use anyhow::{Context, Result}; use tokio::process::Command; use crate::{DesignFile, TemporaryFile, ThreeMfSlicer as ThreeMfSlicerTrait, ThreeMfTemporaryFile}; diff --git a/src/slicer/prusa.rs b/src/slicer/prusa.rs index 3d83c6d..95727d3 100644 --- a/src/slicer/prusa.rs +++ b/src/slicer/prusa.rs @@ -1,8 +1,9 @@ //! Support for the Prusa Slicer (https://github.com/prusa3d/PrusaSlicer/), //! which is based on slic3r. -use anyhow::{Context, Result}; use std::path::{Path, PathBuf}; + +use anyhow::{Context, Result}; use tokio::process::Command; use crate::{ diff --git a/src/sync.rs b/src/sync.rs index 6f1f778..0f42866 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -1,7 +1,9 @@ -use crate::Control; use std::sync::Arc; + use tokio::sync::Mutex; +use crate::Control; + /// Wrapper around an `Arc>`, which helpfully will handle /// the locking to expose a [Control] without the caller having to care /// that this is a shared handle. diff --git a/src/tests.rs b/src/tests.rs index 993b6b6..7d2c33a 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,10 +1,11 @@ -use anyhow::{Context, Result}; -use expectorate::assert_contents; -use pretty_assertions::assert_eq; use std::{ collections::{BTreeMap, HashMap}, sync::Arc, }; + +use anyhow::{Context, Result}; +use expectorate::assert_contents; +use pretty_assertions::assert_eq; use test_context::{test_context, AsyncTestContext}; use testresult::TestResult; use tokio::sync::RwLock; diff --git a/src/traits.rs b/src/traits.rs index d919a50..10d69c7 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -1,7 +1,9 @@ -use crate::{DesignFile, TemporaryFile, Volume}; +use std::future::Future; + use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use std::future::Future; + +use crate::{DesignFile, TemporaryFile, Volume}; /// Specific technique by which this Machine takes a design, and produces /// a real-world 3D object. diff --git a/src/usb/control.rs b/src/usb/control.rs index 9afe54a..0723bee 100644 --- a/src/usb/control.rs +++ b/src/usb/control.rs @@ -1,16 +1,17 @@ -use crate::gcode::Client; -use crate::{ - Control as ControlTrait, GcodeControl as GcodeControlTrait, GcodeTemporaryFile, MachineInfo as MachineInfoTrait, - MachineMakeModel, MachineType, Volume, -}; -use anyhow::Result; use std::sync::Arc; + +use anyhow::Result; use tokio::{ io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, ReadHalf, WriteHalf}, sync::Mutex, }; use tokio_serial::SerialStream; +use crate::{ + gcode::Client, Control as ControlTrait, GcodeControl as GcodeControlTrait, GcodeTemporaryFile, + MachineInfo as MachineInfoTrait, MachineMakeModel, MachineType, Volume, +}; + /// Handle to a USB based gcode 3D printer. #[derive(Clone)] pub struct Usb { diff --git a/src/usb/discover.rs b/src/usb/discover.rs index 415397f..7533254 100644 --- a/src/usb/discover.rs +++ b/src/usb/discover.rs @@ -1,11 +1,13 @@ -use super::UsbVariant; -use crate::{slicer, usb, Discover, Machine, MachineMakeModel}; +use std::{collections::HashMap, sync::Arc}; + use anyhow::Result; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, sync::Arc}; use tokio::sync::RwLock; use tokio_serial::{SerialPortBuilderExt, SerialPortType}; +use super::UsbVariant; +use crate::{slicer, usb, Discover, Machine, MachineMakeModel}; + /// Configuration block for a USB based device. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Config { diff --git a/src/usb/discover_variants.rs b/src/usb/discover_variants.rs index 73d8b0f..eb8c65c 100644 --- a/src/usb/discover_variants.rs +++ b/src/usb/discover_variants.rs @@ -1,6 +1,7 @@ -use crate::{MachineType, Volume}; use serde::{Deserialize, Serialize}; +use crate::{MachineType, Volume}; + macro_rules! usb_devices { ($( $name:ident(