Explorar el Código

rustfmt pass.

Kestrel hace 2 años
padre
commit
92491fb130
Se han modificado 4 ficheros con 62 adiciones y 30 borrados
  1. 1 1
      fleck/src/lib.rs
  2. 51 23
      fleck/src/service.rs
  3. 5 3
      fleck/src/service/lowlevel.rs
  4. 5 3
      fleck/src/service/priority.rs

+ 1 - 1
fleck/src/lib.rs

@@ -10,7 +10,7 @@ pub mod service;
 
 pub mod prelude {
     pub use crate::msg::Message;
-    pub use crate::service::{Service,API as ServiceAPI};
+    pub use crate::service::{Service, API as ServiceAPI};
 }
 
 use crate as fleck;

+ 51 - 23
fleck/src/service.rs

@@ -1,6 +1,6 @@
-use std::{rc::Rc, borrow::BorrowMut};
 use std::cell::RefCell;
 use std::ops::DerefMut;
+use std::{borrow::BorrowMut, rc::Rc};
 
 use crate::io::{FleckIO, Packet};
 
@@ -57,20 +57,36 @@ pub trait OutgoingPriority {
 #[macro_export]
 macro_rules! service_priority {
     ($what:ty, in: $i:ty, out: $o:ty) => {
-        impl fleck::service::IncomingPriority for $what { type Priority = $i; }
-        impl fleck::service::OutgoingPriority for $what { type Priority = $o; }
+        impl fleck::service::IncomingPriority for $what {
+            type Priority = $i;
+        }
+        impl fleck::service::OutgoingPriority for $what {
+            type Priority = $o;
+        }
     };
     ($what:ty, in: $i:ty) => {
-        impl fleck::service::IncomingPriority for $what { type Priority = $i; }
-        impl fleck::service::OutgoingPriority for $what { type Priority = fleck::service::order::Never; }
+        impl fleck::service::IncomingPriority for $what {
+            type Priority = $i;
+        }
+        impl fleck::service::OutgoingPriority for $what {
+            type Priority = fleck::service::order::Never;
+        }
     };
     ($what:ty, out: $o:ty) => {
-        impl fleck::service::IncomingPriority for $what { type Priority = fleck::service::order::Never; }
-        impl fleck::service::OutgoingPriority for $what { type Priority = $o; }
+        impl fleck::service::IncomingPriority for $what {
+            type Priority = fleck::service::order::Never;
+        }
+        impl fleck::service::OutgoingPriority for $what {
+            type Priority = $o;
+        }
     };
     ($what:ty) => {
-        impl fleck::service::IncomingPriority for $what { type Priority = fleck::service::order::Never; }
-        impl fleck::service::OutgoingPriority for $what { type Priority = fleck::service::order::Never; }
+        impl fleck::service::IncomingPriority for $what {
+            type Priority = fleck::service::order::Never;
+        }
+        impl fleck::service::OutgoingPriority for $what {
+            type Priority = fleck::service::order::Never;
+        }
     };
 }
 
@@ -108,46 +124,58 @@ impl ServiceStack {
 
         self.services.push(srv.clone());
         if !<<S as IncomingPriority>::Priority as AbstractServicePriority>::NEVER {
-            self.incoming_order.add_priority::<<S as IncomingPriority>::Priority>(srv.clone());
+            self.incoming_order
+                .add_priority::<<S as IncomingPriority>::Priority>(srv.clone());
         }
         if !<<S as OutgoingPriority>::Priority as AbstractServicePriority>::NEVER {
-            self.incoming_order.add_priority::<<S as OutgoingPriority>::Priority>(srv.clone());
+            self.incoming_order
+                .add_priority::<<S as OutgoingPriority>::Priority>(srv.clone());
         }
     }
 }
 
-
 impl Service for ServiceStack {
     fn process_incoming(&mut self, api: &dyn API, packet: &mut Packet) {
-        let services = self.incoming_cache.get_or_insert_with(|| {
-            self.incoming_order.clone().order()
-        });
+        let services = self
+            .incoming_cache
+            .get_or_insert_with(|| self.incoming_order.clone().order());
 
         for srv in services {
-            srv.as_ref().borrow_mut().deref_mut().process_incoming(api, packet);
+            srv.as_ref()
+                .borrow_mut()
+                .deref_mut()
+                .process_incoming(api, packet);
         }
     }
 
     fn process_outgoing(&mut self, api: &dyn API, packet: &mut Packet) {
-        let services = self.outgoing_cache.get_or_insert_with(|| {
-            self.outgoing_order.clone().order()
-        });
+        let services = self
+            .outgoing_cache
+            .get_or_insert_with(|| self.outgoing_order.clone().order());
 
         for srv in services {
-            srv.as_ref().borrow_mut().deref_mut().process_incoming(api, packet);
+            srv.as_ref()
+                .borrow_mut()
+                .deref_mut()
+                .process_incoming(api, packet);
         }
-        
     }
 
     fn process_minor_tick(&mut self, api: &dyn API) {
         for srv in &self.services {
-            srv.as_ref().borrow_mut().deref_mut().process_minor_tick(api);
+            srv.as_ref()
+                .borrow_mut()
+                .deref_mut()
+                .process_minor_tick(api);
         }
     }
 
     fn process_major_tick(&mut self, api: &dyn API) {
         for srv in &self.services {
-            srv.as_ref().borrow_mut().deref_mut().process_major_tick(api);
+            srv.as_ref()
+                .borrow_mut()
+                .deref_mut()
+                .process_major_tick(api);
         }
     }
 }

+ 5 - 3
fleck/src/service/lowlevel.rs

@@ -1,9 +1,12 @@
-use super::{priority, Service, API, IncomingPriority, Never, OutgoingPriority, order, Priority};
+use super::{order, priority, IncomingPriority, Never, OutgoingPriority, Priority, Service, API};
 use crate::io::Packet;
 
 use crate as fleck;
 
-crate::service_priority!(SendPacket, out: Priority<order::Postprocessing, order::Last>);
+crate::service_priority!(
+    SendPacket,
+    out: Priority<order::Postprocessing, order::Last>
+);
 
 #[derive(Default)]
 pub(crate) struct SendPacket {}
@@ -32,7 +35,6 @@ impl Service for SendPacket {
     }
 }
 
-
 crate::service_priority!(LocalDiscovery);
 pub(crate) struct LocalDiscovery {}
 

+ 5 - 3
fleck/src/service/priority.rs

@@ -40,7 +40,7 @@ pub type MinPriority = Fixpoint<MinTag>;
 pub type MaxPriority = Fixpoint<MaxTag>;
 
 pub struct Fixpoint<Tag: 'static> {
-    _ghost: std::marker::PhantomData<Tag>
+    _ghost: std::marker::PhantomData<Tag>,
 }
 
 impl AbstractServicePriority for Never {
@@ -51,8 +51,10 @@ impl AbstractServicePriority for Never {
 }
 
 impl<Tag: 'static> Default for Fixpoint<Tag> {
-    fn default() -> Self { 
-        Self { _ghost: std::marker::PhantomData }
+    fn default() -> Self {
+        Self {
+            _ghost: std::marker::PhantomData,
+        }
     }
 }