From c94ce06d67b020b8e51836425187cc478179042a Mon Sep 17 00:00:00 2001 From: hauke strasdat Date: Fri, 8 Mar 2024 07:42:09 -0800 Subject: [PATCH] style: format --- Cargo.toml | 4 +-- examples/egui.rs | 7 ++--- examples/moving_average.rs | 12 +++++---- examples/nudge.rs | 3 ++- examples/one_dim_robot.rs | 10 +++++--- examples/print_ticks.rs | 3 ++- examples/zip.rs | 8 ++++-- hollywood_macros/Cargo.toml | 2 +- hollywood_macros/src/actors.rs | 2 +- hollywood_macros/src/actors/zip.rs | 19 +++++++++----- hollywood_macros/src/core.rs | 27 ++++++++++++++----- src/actors.rs | 3 ++- src/actors/egui.rs | 6 +++-- src/actors/nudge.rs | 16 +++++++----- src/actors/periodic.rs | 16 +++++++----- src/actors/printer.rs | 19 ++++++++++---- src/compute/context.rs | 10 ++++++-- src/compute/pipeline.rs | 12 ++++++--- src/compute/topology.rs | 8 +++--- src/core.rs | 25 ++++++++++++------ src/core/actor.rs | 13 +++++----- src/core/actor_builder.rs | 11 ++++---- src/core/connection.rs | 13 +++++----- src/core/connection/outbound_connection.rs | 8 +++--- src/core/connection/request_connection.rs | 10 +++++--- src/core/inbound.rs | 6 +++-- src/core/outbound.rs | 12 ++++++--- src/core/request.rs | 8 ++++-- src/core/runner.rs | 16 +++++------- src/example_actors/moving_average.rs | 17 ++++++++---- src/example_actors/one_dim_robot.rs | 10 +++++--- src/example_actors/one_dim_robot/draw.rs | 4 ++- src/example_actors/one_dim_robot/filter.rs | 30 ++++++++++++++++------ src/example_actors/one_dim_robot/model.rs | 3 ++- src/example_actors/one_dim_robot/sim.rs | 28 +++++++++++++++----- src/introspect/flow_graph.rs | 13 +++++++--- 36 files changed, 273 insertions(+), 141 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a01d998..fc65163 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["actor", "compute", "graph", "pipeline"] license = "Apache-2.0" readme = "README.md" repository = "https://github.com/farm-ng/hollywood/" -version = "0.4.0" +version = "0.5.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -21,7 +21,7 @@ drawille = "0.3.0" eframe = {version = "0.26", features = ["wgpu"], optional = true} env_logger = {version = "0.11.1", optional = true} grid = "0.13.0" -hollywood_macros = {version = "0.4.0", path = "hollywood_macros"} +hollywood_macros = {version = "0.5.0", path = "hollywood_macros"} # hollywood intends to use only very basic features of nalgebra, hence # future versions of nalgebra before the major < 1.0 release are likely to work nalgebra = ">= 0.32, <1.0" diff --git a/examples/egui.rs b/examples/egui.rs index bb12627..85687f7 100644 --- a/examples/egui.rs +++ b/examples/egui.rs @@ -1,8 +1,9 @@ use std::time::Duration; -use hollywood::actors::egui::{ - EguiActor, EguiAppFromBuilder, GenericEguiBuilder, Stream, -}; +use hollywood::actors::egui::EguiActor; +use hollywood::actors::egui::EguiAppFromBuilder; +use hollywood::actors::egui::GenericEguiBuilder; +use hollywood::actors::egui::Stream; use hollywood::compute::Context; use hollywood::core::request::RequestMessage; use hollywood::core::*; diff --git a/examples/moving_average.rs b/examples/moving_average.rs index e614b5b..04569e7 100644 --- a/examples/moving_average.rs +++ b/examples/moving_average.rs @@ -1,11 +1,13 @@ use hollywood::actors::printer::PrinterProp; -use hollywood::actors::{Periodic, Printer}; +use hollywood::actors::Periodic; +use hollywood::actors::Printer; use hollywood::compute::Context; -use hollywood::core::{FromPropState, NullState}; +use hollywood::core::FromPropState; +use hollywood::core::NullState; -use hollywood::example_actors::moving_average::{ - MovingAverage, MovingAverageProp, MovingAverageState, -}; +use hollywood::example_actors::moving_average::MovingAverage; +use hollywood::example_actors::moving_average::MovingAverageProp; +use hollywood::example_actors::moving_average::MovingAverageState; /// pub async fn run_moving_average_example() { diff --git a/examples/nudge.rs b/examples/nudge.rs index 0d1eb83..2a7c611 100644 --- a/examples/nudge.rs +++ b/examples/nudge.rs @@ -1,5 +1,6 @@ use hollywood::actors::printer::PrinterProp; -use hollywood::actors::{Nudge, Printer}; +use hollywood::actors::Nudge; +use hollywood::actors::Printer; use hollywood::compute::Context; use hollywood::core::*; diff --git a/examples/one_dim_robot.rs b/examples/one_dim_robot.rs index 88b6597..7c82798 100644 --- a/examples/one_dim_robot.rs +++ b/examples/one_dim_robot.rs @@ -9,9 +9,13 @@ use hollywood::core::*; use hollywood::example_actors::one_dim_robot::draw::DrawState; use hollywood::example_actors::one_dim_robot::filter::FilterState; -use hollywood::example_actors::one_dim_robot::{ - DrawActor, Filter, NamedFilterState, Robot, Sim, SimState, Stamped, -}; +use hollywood::example_actors::one_dim_robot::DrawActor; +use hollywood::example_actors::one_dim_robot::Filter; +use hollywood::example_actors::one_dim_robot::NamedFilterState; +use hollywood::example_actors::one_dim_robot::Robot; +use hollywood::example_actors::one_dim_robot::Sim; +use hollywood::example_actors::one_dim_robot::SimState; +use hollywood::example_actors::one_dim_robot::Stamped; async fn run_robot_example() { let pipeline = Context::configure(&mut |context| { diff --git a/examples/print_ticks.rs b/examples/print_ticks.rs index 3a2a62f..9fa644b 100644 --- a/examples/print_ticks.rs +++ b/examples/print_ticks.rs @@ -1,5 +1,6 @@ use hollywood::actors::printer::PrinterProp; -use hollywood::actors::{Periodic, Printer}; +use hollywood::actors::Periodic; +use hollywood::actors::Printer; use hollywood::compute::Context; use hollywood::core::*; diff --git a/examples/zip.rs b/examples/zip.rs index f67b0ad..8d45e1a 100644 --- a/examples/zip.rs +++ b/examples/zip.rs @@ -1,6 +1,10 @@ +use hollywood::actors::periodic; use hollywood::actors::printer::PrinterProp; -use hollywood::actors::zip::{Tuple2, Zip2State, ZipPair}; -use hollywood::actors::{periodic, Printer, Zip2}; +use hollywood::actors::zip::Tuple2; +use hollywood::actors::zip::Zip2State; +use hollywood::actors::zip::ZipPair; +use hollywood::actors::Printer; +use hollywood::actors::Zip2; use hollywood::compute::Context; use hollywood::core::*; diff --git a/hollywood_macros/Cargo.toml b/hollywood_macros/Cargo.toml index a8d0f68..f683de4 100644 --- a/hollywood_macros/Cargo.toml +++ b/hollywood_macros/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["actor", "compute", "graph", "pipeline"] license = "Apache-2.0" readme = "../README.md" repository = "https://github.com/farm-ng/hollywood/tree/main/hollywood_macros" -version = "0.4.0" +version = "0.5.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] diff --git a/hollywood_macros/src/actors.rs b/hollywood_macros/src/actors.rs index d8390f9..16a80cb 100644 --- a/hollywood_macros/src/actors.rs +++ b/hollywood_macros/src/actors.rs @@ -1 +1 @@ -pub mod zip; \ No newline at end of file +pub mod zip; diff --git a/hollywood_macros/src/actors/zip.rs b/hollywood_macros/src/actors/zip.rs index e46a423..0ca4318 100644 --- a/hollywood_macros/src/actors/zip.rs +++ b/hollywood_macros/src/actors/zip.rs @@ -1,6 +1,11 @@ use proc_macro2::TokenStream; -use quote::{format_ident, quote}; -use syn::{parse::Parse, parse::ParseStream, parse2, LitInt, Result}; +use quote::format_ident; +use quote::quote; +use syn::parse::Parse; +use syn::parse::ParseStream; +use syn::parse2; +use syn::LitInt; +use syn::Result; struct ZipInput { num_fields: usize, @@ -156,9 +161,9 @@ pub(crate) fn zip_state_n_impl(input: TokenStream) -> TokenStream { let heap_item = format_ident!("item{}_heap", i); let item = format_ident!("Item{}", i); // Corrected this line let pair = quote! { ZipPair<#i, Key, #item> }; - quote! { + quote! { /// Heap for the Xth inbound channel. - pub #heap_item: std::collections::BinaryHeap> + pub #heap_item: std::collections::BinaryHeap> } }); @@ -245,7 +250,7 @@ pub(crate) fn zip_inbound_message_n_impl(input: TokenStream) -> TokenStream { Key: Ord + Clone + Debug + Sync + Send + 'static, #( #type_with_bounds_seq ),* > { - #( + #( /// Inbound message for the Xth inbound channel. #type_seq(ZipPair<#i_seq, Key, #type_seq>) ),* @@ -406,9 +411,9 @@ pub(crate) fn zip_inbound_n_impl(input: TokenStream) -> TokenStream { + Sync + Send + 'static, #( #type_with_bounds_seq ),* > { - #( + #( /// Inbound channel for the Xth inbound channel. - pub #item_seq5: #channel + pub #item_seq5: #channel ),* } diff --git a/hollywood_macros/src/core.rs b/hollywood_macros/src/core.rs index 4600252..ca049c0 100644 --- a/hollywood_macros/src/core.rs +++ b/hollywood_macros/src/core.rs @@ -1,10 +1,23 @@ -use convert_case::{Case, Casing}; +use convert_case::Case; +use convert_case::Casing; use proc_macro2::TokenStream; use quote::quote; -use syn::{ - parse::Parse, parse::ParseStream, parse2, Error, Fields, Generics, Ident, Item, ItemEnum, - ItemStruct, Path, PathArguments, Result, Token, Type, TypePath, -}; +use syn::parse::Parse; +use syn::parse::ParseStream; +use syn::parse2; +use syn::Error; +use syn::Fields; +use syn::Generics; +use syn::Ident; +use syn::Item; +use syn::ItemEnum; +use syn::ItemStruct; +use syn::Path; +use syn::PathArguments; +use syn::Result; +use syn::Token; +use syn::Type; +use syn::TypePath; /// Documentation is in the hollywood crate. pub(crate) fn actor_outputs_impl(_attr: TokenStream, item: TokenStream) -> TokenStream { @@ -142,7 +155,9 @@ pub(crate) fn actor_requests_impl(_attr: TokenStream, item: TokenStream) -> Toke } }); - let field0 = fields.first().expect("Request struct must have at least one field"); + let field0 = fields + .first() + .expect("Request struct must have at least one field"); let m_type = is_request_type(&field0.ty).unwrap()[2]; let gen = quote! { diff --git a/src/actors.rs b/src/actors.rs index 73aba89..0326ad5 100644 --- a/src/actors.rs +++ b/src/actors.rs @@ -4,7 +4,8 @@ pub use periodic::Periodic; /// Generic printer actor. pub mod printer; -pub use printer::{Printer, PrinterProp}; +pub use printer::Printer; +pub use printer::PrinterProp; /// Nudge actor. pub mod nudge; diff --git a/src/actors/egui.rs b/src/actors/egui.rs index 2f16d3e..2b00fbc 100644 --- a/src/actors/egui.rs +++ b/src/actors/egui.rs @@ -1,8 +1,10 @@ -use crate::compute::{CancelRequest, Context}; +use crate::compute::CancelRequest; +use crate::compute::Context; use crate::core::*; use std::fmt::Debug; -use self::request::{IsRequestMessage, RequestMessage}; +use self::request::IsRequestMessage; +use self::request::RequestMessage; /// The inbound message for the egui actor. #[derive(Clone, Debug, Default)] diff --git a/src/actors/nudge.rs b/src/actors/nudge.rs index 8e0f8fd..d3e499d 100644 --- a/src/actors/nudge.rs +++ b/src/actors/nudge.rs @@ -7,13 +7,17 @@ use crate::compute::context::Context; use crate::core::connection::ConnectionEnum; use crate::core::NullState; +use crate::core::actor::ActorNode; +use crate::core::actor::FromPropState; +use crate::core::actor::GenericActor; +use crate::core::inbound::ForwardMessage; +use crate::core::inbound::NullInbound; +use crate::core::inbound::NullMessage; +use crate::core::outbound::Activate; +use crate::core::outbound::OutboundChannel; +use crate::core::outbound::OutboundHub; use crate::core::request::NullRequest; -use crate::core::{ - actor::{ActorNode, FromPropState, GenericActor}, - inbound::{ForwardMessage, NullInbound, NullMessage}, - outbound::{Activate, OutboundChannel, OutboundHub}, - runner::Runner, -}; +use crate::core::runner::Runner; /// Prop for the nudge actor. #[derive(Clone, Debug, Default)] diff --git a/src/actors/periodic.rs b/src/actors/periodic.rs index ae8d6db..8a76c40 100644 --- a/src/actors/periodic.rs +++ b/src/actors/periodic.rs @@ -5,13 +5,17 @@ use async_trait::async_trait; use crate::compute::context::Context; use crate::core::connection::ConnectionEnum; +use crate::core::actor::ActorNode; +use crate::core::actor::FromPropState; +use crate::core::actor::GenericActor; +use crate::core::inbound::ForwardMessage; +use crate::core::inbound::NullInbound; +use crate::core::inbound::NullMessage; +use crate::core::outbound::Activate; +use crate::core::outbound::OutboundChannel; +use crate::core::outbound::OutboundHub; use crate::core::request::NullRequest; -use crate::core::{ - actor::{ActorNode, FromPropState, GenericActor}, - inbound::{ForwardMessage, NullInbound, NullMessage}, - outbound::{Activate, OutboundChannel, OutboundHub}, - runner::Runner, -}; +use crate::core::runner::Runner; /// A periodic actor. /// diff --git a/src/actors/printer.rs b/src/actors/printer.rs index 5291c5b..859bc01 100644 --- a/src/actors/printer.rs +++ b/src/actors/printer.rs @@ -1,11 +1,20 @@ -use std::fmt::{Debug, Display}; +use std::fmt::Debug; +use std::fmt::Display; use hollywood_macros::actor_inputs; -use crate::core::{ - request::NullRequest, Actor, ActorBuilder, DefaultRunner, FromPropState, InboundChannel, - InboundHub, InboundMessage, InboundMessageNew, NullOutbound, NullState, OnMessage, -}; +use crate::core::request::NullRequest; +use crate::core::Actor; +use crate::core::ActorBuilder; +use crate::core::DefaultRunner; +use crate::core::FromPropState; +use crate::core::InboundChannel; +use crate::core::InboundHub; +use crate::core::InboundMessage; +use crate::core::InboundMessageNew; +use crate::core::NullOutbound; +use crate::core::NullState; +use crate::core::OnMessage; /// Configuration properties for the printer actor. #[derive(Clone, Debug)] diff --git a/src/compute/context.rs b/src/compute/context.rs index fb6d4c2..968ad4b 100644 --- a/src/compute/context.rs +++ b/src/compute/context.rs @@ -1,8 +1,14 @@ use std::marker::PhantomData; use std::sync::Arc; -use crate::compute::{CancelRequest, Pipeline, Topology}; -use crate::core::{ActorNode, InboundChannel, InboundMessage, OutboundChannel, OutboundConnection}; +use crate::compute::CancelRequest; +use crate::compute::Pipeline; +use crate::compute::Topology; +use crate::core::ActorNode; +use crate::core::InboundChannel; +use crate::core::InboundMessage; +use crate::core::OutboundChannel; +use crate::core::OutboundConnection; /// The context of the compute graph which is used to configure the network topology. /// diff --git a/src/compute/pipeline.rs b/src/compute/pipeline.rs index a50b34a..4ae87f3 100644 --- a/src/compute/pipeline.rs +++ b/src/compute/pipeline.rs @@ -1,9 +1,13 @@ use std::mem::swap; -use crate::compute::{Context, Topology}; -use crate::core::{ - ActorNode, InboundMessage, InboundMessageNew, NullOutbound, NullProp, NullState, -}; +use crate::compute::Context; +use crate::compute::Topology; +use crate::core::ActorNode; +use crate::core::InboundMessage; +use crate::core::InboundMessageNew; +use crate::core::NullOutbound; +use crate::core::NullProp; +use crate::core::NullState; /// Message to request stop execution of the compute pipeline. #[derive(Debug, Clone)] diff --git a/src/compute/topology.rs b/src/compute/topology.rs index b5c0b2a..506f72f 100644 --- a/src/compute/topology.rs +++ b/src/compute/topology.rs @@ -2,10 +2,10 @@ use std::collections::BTreeSet; use petgraph::stable_graph::StableDiGraph; -use crate::{ - core::{InboundChannel, InboundMessage, OutboundChannel}, - introspect::flow_graph::FlowGraph, -}; +use crate::core::InboundChannel; +use crate::core::InboundMessage; +use crate::core::OutboundChannel; +use crate::introspect::flow_graph::FlowGraph; // A node in a compute graph. #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] diff --git a/src/core.rs b/src/core.rs index f4d50dc..df37d1b 100644 --- a/src/core.rs +++ b/src/core.rs @@ -2,8 +2,9 @@ /// Actor pub mod actor; +pub use actor::Actor; pub(crate) use actor::ActorNode; -pub use actor::{Actor, FromPropState}; +pub use actor::FromPropState; /// Actor builder pub mod actor_builder; @@ -12,19 +13,26 @@ pub use actor_builder::ActorBuilder; /// Inbound pub mod inbound; -pub use inbound::{ - InboundChannel, InboundHub, InboundMessage, InboundMessageNew, NullInbound, NullMessage, - OnMessage, -}; +pub use inbound::InboundChannel; +pub use inbound::InboundHub; +pub use inbound::InboundMessage; +pub use inbound::InboundMessageNew; +pub use inbound::NullInbound; +pub use inbound::NullMessage; +pub use inbound::OnMessage; /// Outbound pub mod outbound; +pub use outbound::Activate; +pub use outbound::NullOutbound; +pub use outbound::OutboundChannel; pub(crate) use outbound::OutboundConnection; -pub use outbound::{Activate, NullOutbound, OutboundChannel, OutboundHub}; +pub use outbound::OutboundHub; /// Request pub mod request; -pub use request::{NullRequest, RequestHub}; +pub use request::NullRequest; +pub use request::RequestHub; /// Connection pub mod connection; @@ -35,4 +43,5 @@ pub use runner::DefaultRunner; /// State pub mod value; -pub use value::{NullProp, NullState}; +pub use value::NullProp; +pub use value::NullState; diff --git a/src/core/actor.rs b/src/core/actor.rs index e37ec1b..e2813eb 100644 --- a/src/core/actor.rs +++ b/src/core/actor.rs @@ -3,12 +3,13 @@ use std::collections::HashMap; use tokio::select; use crate::compute::context::Context; -use crate::core::{ - actor_builder::ActorBuilder, - inbound::{ForwardMessage, InboundHub, InboundMessage}, - outbound::OutboundHub, - runner::{DefaultRunner, Runner}, -}; +use crate::core::actor_builder::ActorBuilder; +use crate::core::inbound::ForwardMessage; +use crate::core::inbound::InboundHub; +use crate::core::inbound::InboundMessage; +use crate::core::outbound::OutboundHub; +use crate::core::runner::DefaultRunner; +use crate::core::runner::Runner; use super::request::RequestHub; diff --git a/src/core/actor_builder.rs b/src/core/actor_builder.rs index c7ffe82..e99a698 100644 --- a/src/core/actor_builder.rs +++ b/src/core/actor_builder.rs @@ -1,10 +1,9 @@ use crate::compute::context::Context; -use crate::core::{ - actor::GenericActor, - inbound::{InboundHub, InboundMessage}, - outbound::OutboundHub, - runner::Runner, -}; +use crate::core::actor::GenericActor; +use crate::core::inbound::InboundHub; +use crate::core::inbound::InboundMessage; +use crate::core::outbound::OutboundHub; +use crate::core::runner::Runner; use super::actor::ForwardTable; use super::request::RequestHub; diff --git a/src/core/connection.rs b/src/core/connection.rs index 57526d4..502084d 100644 --- a/src/core/connection.rs +++ b/src/core/connection.rs @@ -1,11 +1,10 @@ use std::sync::Arc; -use self::{ - outbound_connection::{ActiveConnection, ConnectionConfig}, - request_connection::{ - ActiveRequestConnection, GenericRequestConnection, RequestConnectionConfig, - }, -}; +use self::outbound_connection::ActiveConnection; +use self::outbound_connection::ConnectionConfig; +use self::request_connection::ActiveRequestConnection; +use self::request_connection::GenericRequestConnection; +use self::request_connection::RequestConnectionConfig; use super::outbound::GenericConnection; @@ -21,7 +20,7 @@ pub mod request_connection; type ConnectionRegister = Vec + Send + Sync>>; -/// Connection +/// Connection pub enum ConnectionEnum { /// Configuration of the connection Config(ConnectionConfig), diff --git a/src/core/connection/outbound_connection.rs b/src/core/connection/outbound_connection.rs index 3604aee..72f0f58 100644 --- a/src/core/connection/outbound_connection.rs +++ b/src/core/connection/outbound_connection.rs @@ -1,8 +1,10 @@ use std::sync::Arc; -use crate::core::{outbound::GenericConnection, Activate}; +use crate::core::outbound::GenericConnection; +use crate::core::Activate; -use super::{ConnectionEnum, ConnectionRegister}; +use super::ConnectionEnum; +use super::ConnectionRegister; /// Connection configuration pub struct ConnectionConfig { @@ -26,7 +28,7 @@ impl Drop for ConnectionConfig { } impl ConnectionConfig { - /// + /// pub fn new() -> Self { let (connection_launch_pad, connection_landing_pad) = tokio::sync::oneshot::channel(); Self { diff --git a/src/core/connection/request_connection.rs b/src/core/connection/request_connection.rs index 6b81910..a4a0d10 100644 --- a/src/core/connection/request_connection.rs +++ b/src/core/connection/request_connection.rs @@ -1,10 +1,14 @@ -use std::{marker::PhantomData, sync::Arc}; +use std::marker::PhantomData; +use std::sync::Arc; use tokio::sync::mpsc::error::SendError; -use crate::core::{Activate, InboundMessage, InboundMessageNew}; +use crate::core::Activate; +use crate::core::InboundMessage; +use crate::core::InboundMessageNew; -use super::{RequestConnectionEnum, RequestConnectionRegister}; +use super::RequestConnectionEnum; +use super::RequestConnectionRegister; pub(crate) trait GenericRequestConnection: Send + Sync { fn send_impl(&self, msg: T); diff --git a/src/core/inbound.rs b/src/core/inbound.rs index 23d43cb..1a12f75 100644 --- a/src/core/inbound.rs +++ b/src/core/inbound.rs @@ -1,7 +1,9 @@ use crate::compute::context::Context; -use crate::core::{actor_builder::ActorBuilder, outbound::OutboundHub}; +use crate::core::actor_builder::ActorBuilder; +use crate::core::outbound::OutboundHub; -use super::request::{NullRequest, RequestHub}; +use super::request::NullRequest; +use super::request::RequestHub; /// The inbound hub is a collection of inbound channels. pub trait InboundHub, M: InboundMessage>: diff --git a/src/core/outbound.rs b/src/core/outbound.rs index 541e68d..dd116ff 100644 --- a/src/core/outbound.rs +++ b/src/core/outbound.rs @@ -1,10 +1,14 @@ -use std::{marker::PhantomData, sync::Arc}; +use std::marker::PhantomData; +use std::sync::Arc; use tokio::sync::mpsc::error::SendError; use super::connection::ConnectionEnum; use crate::compute::context::Context; -use crate::core::inbound::{InboundChannel, InboundMessage, InboundMessageNew}; -use std::fmt::{Debug, Formatter}; +use crate::core::inbound::InboundChannel; +use crate::core::inbound::InboundMessage; +use crate::core::inbound::InboundMessageNew; +use std::fmt::Debug; +use std::fmt::Formatter; /// OutboundHub is a collection of outbound channels for the actor. pub trait OutboundHub: Send + Sync + 'static + Activate { @@ -70,7 +74,7 @@ impl OutboundChannel, >( &mut self, diff --git a/src/core/request.rs b/src/core/request.rs index f82a53a..7ad57df 100644 --- a/src/core/request.rs +++ b/src/core/request.rs @@ -1,11 +1,15 @@ use std::fmt::Debug; -use std::{marker::PhantomData, sync::Arc}; +use std::marker::PhantomData; +use std::sync::Arc; use crate::compute::Context; use super::connection::request_connection::RequestConnection; use super::connection::RequestConnectionEnum; -use super::{Activate, InboundChannel, InboundMessage, InboundMessageNew}; +use super::Activate; +use super::InboundChannel; +use super::InboundMessage; +use super::InboundMessageNew; /// A request hub is used to send requests to other actors which will reply later. pub trait RequestHub: Send + Sync + 'static + Activate { diff --git a/src/core/runner.rs b/src/core/runner.rs index 1ab55fc..ceb2224 100644 --- a/src/core/runner.rs +++ b/src/core/runner.rs @@ -1,13 +1,11 @@ -use crate::core::{ - inbound::{InboundHub, InboundMessage}, - outbound::OutboundHub, -}; +use crate::core::inbound::InboundHub; +use crate::core::inbound::InboundMessage; +use crate::core::outbound::OutboundHub; -use super::{ - actor::{ActorNodeImpl, ForwardTable}, - request::RequestHub, - ActorNode, -}; +use super::actor::ActorNodeImpl; +use super::actor::ForwardTable; +use super::request::RequestHub; +use super::ActorNode; /// Runner executes the pipeline. pub trait Runner< diff --git a/src/example_actors/moving_average.rs b/src/example_actors/moving_average.rs index ce90990..b240e2b 100644 --- a/src/example_actors/moving_average.rs +++ b/src/example_actors/moving_average.rs @@ -3,15 +3,22 @@ use crate::macros::*; // needed for actor_outputs macro pub use crate::compute::Context; use crate::core::request::NullRequest; -pub use crate::core::{Activate, OutboundChannel, OutboundHub}; +pub use crate::core::Activate; +pub use crate::core::OutboundChannel; +pub use crate::core::OutboundHub; // needed for actor_inputs macro -pub use crate::core::{ - ActorBuilder, InboundChannel, InboundHub, InboundMessage, InboundMessageNew, OnMessage, -}; +pub use crate::core::ActorBuilder; +pub use crate::core::InboundChannel; +pub use crate::core::InboundHub; +pub use crate::core::InboundMessage; +pub use crate::core::InboundMessageNew; +pub use crate::core::OnMessage; // needed for actor macro -pub use crate::core::{Actor, DefaultRunner, FromPropState}; +pub use crate::core::Actor; +pub use crate::core::DefaultRunner; +pub use crate::core::FromPropState; /// Outbound hub for the MovingAverage. #[actor_outputs] diff --git a/src/example_actors/one_dim_robot.rs b/src/example_actors/one_dim_robot.rs index 4696920..ca5eeb7 100644 --- a/src/example_actors/one_dim_robot.rs +++ b/src/example_actors/one_dim_robot.rs @@ -1,14 +1,18 @@ /// One dimensional world and sensor model pub mod model; -pub use model::{RangeMeasurementModel, Robot, Stamped}; +pub use model::RangeMeasurementModel; +pub use model::Robot; +pub use model::Stamped; /// Simulation actor for the robot in the one dimensional world. pub mod sim; -pub use sim::{Sim, SimState}; +pub use sim::Sim; +pub use sim::SimState; /// Kalman filter actor for the one dimensional robot. pub mod filter; -pub use filter::{Filter, NamedFilterState}; +pub use filter::Filter; +pub use filter::NamedFilterState; /// Drawing actor for the one dimensional robot. /// diff --git a/src/example_actors/one_dim_robot/draw.rs b/src/example_actors/one_dim_robot/draw.rs index c85e17c..d46ccb9 100644 --- a/src/example_actors/one_dim_robot/draw.rs +++ b/src/example_actors/one_dim_robot/draw.rs @@ -4,7 +4,9 @@ use crate::core::InboundMessageNew; use crate::core::NullOutbound; use crate::core::OnMessage; use crate::core::*; -use crate::example_actors::one_dim_robot::{NamedFilterState, Robot, Stamped}; +use crate::example_actors::one_dim_robot::NamedFilterState; +use crate::example_actors::one_dim_robot::Robot; +use crate::example_actors::one_dim_robot::Stamped; use crate::macros::*; use drawille::Canvas; diff --git a/src/example_actors/one_dim_robot/filter.rs b/src/example_actors/one_dim_robot/filter.rs index bb10f31..7fb8865 100644 --- a/src/example_actors/one_dim_robot/filter.rs +++ b/src/example_actors/one_dim_robot/filter.rs @@ -1,13 +1,27 @@ -use std::fmt::{Debug, Display}; +use std::fmt::Debug; +use std::fmt::Display; use crate::compute::Context; -use crate::core::request::{NullRequest, RequestMessage}; -use crate::core::{ - Activate, Actor, ActorBuilder, DefaultRunner, FromPropState, InboundChannel, InboundHub, - InboundMessage, InboundMessageNew, NullProp, OnMessage, OutboundChannel, OutboundHub, -}; -use crate::example_actors::one_dim_robot::{RangeMeasurementModel, Stamped}; -use hollywood_macros::{actor, actor_inputs, actor_outputs}; +use crate::core::request::NullRequest; +use crate::core::request::RequestMessage; +use crate::core::Activate; +use crate::core::Actor; +use crate::core::ActorBuilder; +use crate::core::DefaultRunner; +use crate::core::FromPropState; +use crate::core::InboundChannel; +use crate::core::InboundHub; +use crate::core::InboundMessage; +use crate::core::InboundMessageNew; +use crate::core::NullProp; +use crate::core::OnMessage; +use crate::core::OutboundChannel; +use crate::core::OutboundHub; +use crate::example_actors::one_dim_robot::RangeMeasurementModel; +use crate::example_actors::one_dim_robot::Stamped; +use hollywood_macros::actor; +use hollywood_macros::actor_inputs; +use hollywood_macros::actor_outputs; use super::sim::PingPong; diff --git a/src/example_actors/one_dim_robot/model.rs b/src/example_actors/one_dim_robot/model.rs index 4707a1a..c03095c 100644 --- a/src/example_actors/one_dim_robot/model.rs +++ b/src/example_actors/one_dim_robot/model.rs @@ -1,4 +1,5 @@ -use std::fmt::{Debug, Display}; +use std::fmt::Debug; +use std::fmt::Display; /// A generic value with a timestamp. #[derive(Clone, Debug, Default)] diff --git a/src/example_actors/one_dim_robot/sim.rs b/src/example_actors/one_dim_robot/sim.rs index 70ab8c3..0f15ab7 100644 --- a/src/example_actors/one_dim_robot/sim.rs +++ b/src/example_actors/one_dim_robot/sim.rs @@ -1,14 +1,28 @@ use std::fmt::Debug; -use rand_distr::{Distribution, Normal}; +use rand_distr::Distribution; +use rand_distr::Normal; use crate::compute::Context; -use crate::core::request::{ReplyMessage, RequestChannel, RequestHub}; -use crate::core::{ - Activate, Actor, ActorBuilder, DefaultRunner, FromPropState, InboundChannel, InboundHub, - InboundMessage, InboundMessageNew, NullProp, OnMessage, OutboundChannel, OutboundHub, -}; -use crate::example_actors::one_dim_robot::{RangeMeasurementModel, Robot, Stamped}; +use crate::core::request::ReplyMessage; +use crate::core::request::RequestChannel; +use crate::core::request::RequestHub; +use crate::core::Activate; +use crate::core::Actor; +use crate::core::ActorBuilder; +use crate::core::DefaultRunner; +use crate::core::FromPropState; +use crate::core::InboundChannel; +use crate::core::InboundHub; +use crate::core::InboundMessage; +use crate::core::InboundMessageNew; +use crate::core::NullProp; +use crate::core::OnMessage; +use crate::core::OutboundChannel; +use crate::core::OutboundHub; +use crate::example_actors::one_dim_robot::RangeMeasurementModel; +use crate::example_actors::one_dim_robot::Robot; +use crate::example_actors::one_dim_robot::Stamped; use crate::macros::*; /// Ping-pong request message. diff --git a/src/introspect/flow_graph.rs b/src/introspect/flow_graph.rs index 9fceddc..07c4de7 100644 --- a/src/introspect/flow_graph.rs +++ b/src/introspect/flow_graph.rs @@ -1,10 +1,15 @@ -use std::collections::{HashMap, VecDeque}; +use std::collections::HashMap; +use std::collections::VecDeque; -use drawille::{Canvas, PixelColor}; +use drawille::Canvas; +use drawille::PixelColor; use grid::Grid; -use rand_distr::num_traits::{self, FromPrimitive, ToPrimitive}; +use rand_distr::num_traits::FromPrimitive; +use rand_distr::num_traits::ToPrimitive; +use rand_distr::num_traits::{self}; -use crate::compute::{ActorNode, Topology}; +use crate::compute::ActorNode; +use crate::compute::Topology; /// A super node is an actor with its inbound and outbound channels. pub(crate) struct FlowSuperNode {