Skip to content

Commit 46f5cd7

Browse files
committed
Reformatted.
1 parent dc0bbe7 commit 46f5cd7

File tree

14 files changed

+77
-67
lines changed

14 files changed

+77
-67
lines changed

server/swimos_agent/src/agent_lifecycle/utility/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use crate::event_handler::{
4444
};
4545
use crate::event_handler::{GetAgentUri, HandlerAction, SideEffect};
4646
use crate::item::{
47-
InspectableMapLikeItem, MapLikeItem, MutableMapLikeItem, MutableValueLikeItem, ValueLikeItem
47+
InspectableMapLikeItem, MapLikeItem, MutableMapLikeItem, MutableValueLikeItem, ValueLikeItem,
4848
};
4949
use crate::lanes::command::{CommandLane, DoCommand};
5050
use crate::lanes::demand::{Cue, DemandLane};
@@ -186,7 +186,7 @@ impl<Agent: 'static> HandlerContext<Agent> {
186186
}
187187

188188
/// Create an event handler that will transform the value of a value lane or store of the agent.
189-
///
189+
///
190190
/// #Arguments
191191
/// * `item` - Projection to the value lane or store.
192192
/// * `f` - A closure that produces a new value from a reference to the existing value.
@@ -207,7 +207,7 @@ impl<Agent: 'static> HandlerContext<Agent> {
207207

208208
/// Create an event handler that will inspect the value of a value lane or store and generate a result from it.
209209
/// This differs from using [`Self::get_value`] in that it does not require a clone to be made of the existing value.
210-
///
210+
///
211211
/// #Arguments
212212
/// * `item` - Projection to the value lane or store.
213213
/// * `f` - A closure that produces a value from a reference to the current value of the item.
@@ -257,10 +257,10 @@ impl<Agent: 'static> HandlerContext<Agent> {
257257
&self,
258258
item: fn(&Agent) -> &Item,
259259
key: K,
260-
f: F
260+
f: F,
261261
) -> impl HandlerAction<Agent, Completion = U> + Send + 'a
262262
where
263-
Agent: 'static,
263+
Agent: 'static,
264264
Item: InspectableMapLikeItem<K, V> + 'static,
265265
K: Send + Clone + Eq + Hash + 'static,
266266
V: Borrow<B> + 'static,
@@ -270,7 +270,6 @@ impl<Agent: 'static> HandlerContext<Agent> {
270270
Item::with_entry_handler::<Agent, F, B, U>(item, key, f)
271271
}
272272

273-
274273
/// Create an event handler that will transform the value in an entry of a map lane or store of the agent.
275274
/// If map contains an entry with that key, it will be updated (or removed) based on the result of the calling
276275
/// the closure on it. If the map does not contain an entry with that key, the closure will be called with [`None`]
@@ -775,7 +774,6 @@ impl<Agent: 'static> HandlerContext<Agent> {
775774
pub fn stop(&self) -> impl EventHandler<Agent> + Send + 'static {
776775
HandlerActionExt::<Agent>::discard(Stop)
777776
}
778-
779777
}
780778

781779
pub struct JoinValueContext<Agent, K, V> {

server/swimos_agent/src/item.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,4 @@ pub trait MutableValueLikeItem<T> {
145145
C: 'static;
146146

147147
fn set_handler<C: 'static>(projection: fn(&C) -> &Self, value: T) -> Self::SetHandler<C>;
148-
149148
}

server/swimos_agent/src/lanes/join/map/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ use std::{
1717
borrow::Borrow,
1818
cell::RefCell,
1919
collections::{hash_map::Entry, BTreeSet, HashMap, HashSet},
20-
hash::Hash, marker::PhantomData,
20+
hash::Hash,
21+
marker::PhantomData,
2122
};
2223

2324
use bytes::BytesMut;
@@ -674,9 +675,7 @@ pub struct JoinMapLaneWithEntry<C, L, K, V, F, B: ?Sized> {
674675
}
675676

676677
impl<C, L, K, V, F, B: ?Sized> JoinMapLaneWithEntry<C, L, K, V, F, B> {
677-
678-
pub fn new(projection: for<'a> fn(&'a C) -> &'a JoinMapLane<L, K, V>,
679-
key: K, f: F) -> Self {
678+
pub fn new(projection: for<'a> fn(&'a C) -> &'a JoinMapLane<L, K, V>, key: K, f: F) -> Self {
680679
JoinMapLaneWithEntry {
681680
projection,
682681
key,
@@ -758,7 +757,8 @@ where
758757
C: 'a,
759758
B: ?Sized + 'static,
760759
V: Borrow<B>,
761-
F: FnOnce(Option<&B>) -> U + Send + 'a {
760+
F: FnOnce(Option<&B>) -> U + Send + 'a,
761+
{
762762
JoinMapLaneWithEntry::new(projection, key, f)
763763
}
764-
}
764+
}

server/swimos_agent/src/lanes/join/map/tests.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ fn join_map_lane_with_entry_event_handler() {
332332
let meta = make_meta(&uri, &route_params);
333333
let agent = TestAgent::with_init();
334334

335-
let mut handler = JoinMapLaneWithEntry::new(TestAgent::LANE, K1, |v: Option<&str>| v.map(str::to_owned));
335+
let mut handler =
336+
JoinMapLaneWithEntry::new(TestAgent::LANE, K1, |v: Option<&str>| v.map(str::to_owned));
336337

337338
let result = handler.step(
338339
&mut dummy_context(&mut HashMap::new(), &mut BytesMut::new()),
@@ -351,7 +352,9 @@ fn join_map_lane_with_entry_event_handler() {
351352
StepResult::Fail(EventHandlerError::SteppedAfterComplete)
352353
));
353354

354-
let mut handler = JoinMapLaneWithEntry::new(TestAgent::LANE, ABSENT, |v: Option<&str>| v.map(str::to_owned));
355+
let mut handler = JoinMapLaneWithEntry::new(TestAgent::LANE, ABSENT, |v: Option<&str>| {
356+
v.map(str::to_owned)
357+
});
355358

356359
let result = handler.step(
357360
&mut dummy_context(&mut HashMap::new(), &mut BytesMut::new()),

server/swimos_agent/src/lanes/join/value/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,7 @@ pub struct JoinValueLaneWithEntry<C, K, V, F, B: ?Sized> {
436436
}
437437

438438
impl<C, K, V, F, B: ?Sized> JoinValueLaneWithEntry<C, K, V, F, B> {
439-
440-
pub fn new(projection: for<'a> fn(&'a C) -> &'a JoinValueLane<K, V>,
441-
key: K, f: F) -> Self {
439+
pub fn new(projection: for<'a> fn(&'a C) -> &'a JoinValueLane<K, V>, key: K, f: F) -> Self {
442440
JoinValueLaneWithEntry {
443441
projection,
444442
key,
@@ -473,7 +471,6 @@ where
473471
}
474472
}
475473

476-
477474
impl<K, V> MapLikeItem<K, V> for JoinValueLane<K, V>
478475
where
479476
K: Clone + Eq + Hash + Send + 'static,
@@ -519,7 +516,8 @@ where
519516
C: 'a,
520517
B: ?Sized + 'static,
521518
V: Borrow<B>,
522-
F: FnOnce(Option<&B>) -> U + Send + 'a {
519+
F: FnOnce(Option<&B>) -> U + Send + 'a,
520+
{
523521
JoinValueLaneWithEntry::new(projection, key, f)
524522
}
525-
}
523+
}

server/swimos_agent/src/lanes/join/value/tests.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ fn join_value_lane_with_entry_event_handler() {
195195
let meta = make_meta(&uri, &route_params);
196196
let agent = TestAgent::with_init();
197197

198-
let mut handler = JoinValueLaneWithEntry::new(TestAgent::LANE, K1, |v: Option<&str>| v.map(str::to_owned));
198+
let mut handler =
199+
JoinValueLaneWithEntry::new(TestAgent::LANE, K1, |v: Option<&str>| v.map(str::to_owned));
199200

200201
let result = handler.step(
201202
&mut dummy_context(&mut HashMap::new(), &mut BytesMut::new()),
@@ -214,7 +215,9 @@ fn join_value_lane_with_entry_event_handler() {
214215
StepResult::Fail(EventHandlerError::SteppedAfterComplete)
215216
));
216217

217-
let mut handler = JoinValueLaneWithEntry::new(TestAgent::LANE, ABSENT, |v: Option<&str>| v.map(str::to_owned));
218+
let mut handler = JoinValueLaneWithEntry::new(TestAgent::LANE, ABSENT, |v: Option<&str>| {
219+
v.map(str::to_owned)
220+
});
218221

219222
let result = handler.step(
220223
&mut dummy_context(&mut HashMap::new(), &mut BytesMut::new()),

server/swimos_agent/src/lanes/map/mod.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ impl<K, V> MapLane<K, V>
150150
where
151151
K: Eq + Hash,
152152
{
153-
154153
pub fn with_entry<F, B, U>(&self, key: &K, f: F) -> U
155154
where
156155
B: ?Sized,
@@ -159,7 +158,6 @@ where
159158
{
160159
self.inner.borrow().with_entry(key, f)
161160
}
162-
163161
}
164162

165163
const INFALLIBLE_SER: &str = "Serializing lane responses to recon should be infallible.";
@@ -670,7 +668,7 @@ where
670668
B: ?Sized +'static,
671669
V: Borrow<B>,
672670
F: FnOnce(Option<&B>) -> U + Send + 'a;
673-
671+
674672
fn with_entry_handler<'a, C, F, B, U>(
675673
projection: fn(&C) -> &Self,
676674
key: K,
@@ -679,9 +677,10 @@ where
679677
where
680678
Self: 'static,
681679
C: 'a,
682-
B: ?Sized +'static,
680+
B: ?Sized + 'static,
683681
V: Borrow<B>,
684-
F: FnOnce(Option<&B>) -> U + Send + 'a {
682+
F: FnOnce(Option<&B>) -> U + Send + 'a,
683+
{
685684
MapLaneWithEntry::new(projection, key, f)
686685
}
687686
}
@@ -718,13 +717,13 @@ where
718717
fn clear_handler<C: 'static>(projection: fn(&C) -> &Self) -> Self::ClearHandler<C> {
719718
MapLaneClear::new(projection)
720719
}
721-
720+
722721
type TransformEntryHandler<'a, C, F> = MapLaneTransformEntry<C, K, V, F>
723722
where
724723
Self: 'static,
725724
C: 'a,
726725
F: FnOnce(Option<&V>) -> Option<V> + Send + 'a;
727-
726+
728727
fn transform_entry_handler<'a, C, F>(
729728
projection: fn(&C) -> &Self,
730729
key: K,
@@ -733,8 +732,8 @@ where
733732
where
734733
Self: 'static,
735734
C: 'a,
736-
F: FnOnce(Option<&V>) -> Option<V> + Send + 'a {
737-
MapLaneTransformEntry::new(projection, key, f)
735+
F: FnOnce(Option<&V>) -> Option<V> + Send + 'a,
736+
{
737+
MapLaneTransformEntry::new(projection, key, f)
738738
}
739-
740739
}

server/swimos_agent/src/lanes/map/tests.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use crate::{
3737
lanes::{
3838
map::{
3939
MapLane, MapLaneClear, MapLaneEvent, MapLaneGet, MapLaneGetMap, MapLaneRemove,
40-
MapLaneSync, MapLaneUpdate, MapLaneTransformEntry,
40+
MapLaneSync, MapLaneTransformEntry, MapLaneUpdate,
4141
},
4242
LaneItem,
4343
},
@@ -824,7 +824,9 @@ fn map_lane_with_entry_handler_absent() {
824824
let meta = make_meta(&uri, &route_params);
825825
let agent = TestAgent::with_init();
826826

827-
let mut handler = MapLaneWithEntry::new(TestAgent::LANE, ABSENT, |maybe_v: Option<&str>| maybe_v.map(str::to_owned));
827+
let mut handler = MapLaneWithEntry::new(TestAgent::LANE, ABSENT, |maybe_v: Option<&str>| {
828+
maybe_v.map(str::to_owned)
829+
});
828830

829831
let result = handler.step(
830832
&mut dummy_context(&mut HashMap::new(), &mut BytesMut::new()),
@@ -841,12 +843,14 @@ fn map_lane_with_entry_handler_present() {
841843
let meta = make_meta(&uri, &route_params);
842844
let agent = TestAgent::with_init();
843845

844-
let mut handler = MapLaneWithEntry::new(TestAgent::LANE, K1, |maybe_v: Option<&str>| maybe_v.map(str::to_owned));
846+
let mut handler = MapLaneWithEntry::new(TestAgent::LANE, K1, |maybe_v: Option<&str>| {
847+
maybe_v.map(str::to_owned)
848+
});
845849

846850
let result = handler.step(
847851
&mut dummy_context(&mut HashMap::new(), &mut BytesMut::new()),
848852
meta,
849853
&agent,
850854
);
851855
check_result(result, false, false, Some(Some(V1.to_owned())));
852-
}
856+
}

server/swimos_agent/src/lanes/value/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,17 +274,19 @@ impl<C, T> HandlerAction<C> for ValueLaneSync<C, T> {
274274
}
275275
}
276276

277-
pub struct ValueLaneWithValue<C, T, F, B: ?Sized> {
277+
pub struct ValueLaneWithValue<C, T, F, B: ?Sized> {
278278
projection: for<'a> fn(&'a C) -> &'a ValueLane<T>,
279279
f: Option<F>,
280280
_type: PhantomData<fn(&B)>,
281281
}
282282

283-
impl<C, T, F, B: ?Sized,> ValueLaneWithValue<C, T, F, B> {
284-
285-
pub fn new(projection: for<'a> fn(&'a C) -> &'a ValueLane<T>,
286-
f: F) -> Self {
287-
ValueLaneWithValue { projection, f: Some(f), _type: PhantomData }
283+
impl<C, T, F, B: ?Sized> ValueLaneWithValue<C, T, F, B> {
284+
pub fn new(projection: for<'a> fn(&'a C) -> &'a ValueLane<T>, f: F) -> Self {
285+
ValueLaneWithValue {
286+
projection,
287+
f: Some(f),
288+
_type: PhantomData,
289+
}
288290
}
289291
}
290292

@@ -377,5 +379,4 @@ where
377379
fn set_handler<C: 'static>(projection: fn(&C) -> &Self, value: T) -> Self::SetHandler<C> {
378380
ValueLaneSet::new(projection, value)
379381
}
380-
381382
}

server/swimos_agent/src/lanes/value/tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl Default for TestAgent {
287287
fn default() -> Self {
288288
Self {
289289
lane: ValueLane::new(LANE_ID, 0),
290-
str_lane: ValueLane::new(STR_LANE_ID, "hello".to_string())
290+
str_lane: ValueLane::new(STR_LANE_ID, "hello".to_string()),
291291
}
292292
}
293293
}
@@ -478,5 +478,4 @@ fn value_lane_with_value_event_handler() {
478478
result,
479479
StepResult::Fail(EventHandlerError::SteppedAfterComplete)
480480
));
481-
482481
}

0 commit comments

Comments
 (0)