From 0d0b43ed8819e66a0888eb6d1d1f47b171ae62e0 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 7 Feb 2022 19:29:52 +0300 Subject: fix(users/tazjin): rustfmt code with non-default settings rustfmt only sometimes detects path-based nested config files (probably some kind of race?), so my users folder uses a separate formatting check for rustfmt to avoid flaky CI. Enough flakes around already ... Change-Id: Ifd862f9974f071b3a256643dd8e56c019116156a Reviewed-on: https://cl.tvl.fyi/c/depot/+/5242 Reviewed-by: tazjin Autosubmit: tazjin Tested-by: BuildkiteCI --- users/tazjin/finito/finito-core/src/lib.rs | 41 +++++++++++++++++------------- 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'users/tazjin/finito/finito-core/src/lib.rs') diff --git a/users/tazjin/finito/finito-core/src/lib.rs b/users/tazjin/finito/finito-core/src/lib.rs index 517bfad2bc74..aaec03a77b42 100644 --- a/users/tazjin/finito/finito-core/src/lib.rs +++ b/users/tazjin/finito/finito-core/src/lib.rs @@ -38,8 +38,8 @@ //! //! * an event type representing all possible events in the machine //! -//! * an action type representing a description of all possible -//! side-effects of the machine +//! * an action type representing a description of all possible side-effects +//! of the machine //! //! Using the definition above we can now say that a transition in a //! state-machine, involving these three types, takes an initial state @@ -92,14 +92,13 @@ //! //! * `finito`: Core components and classes of Finito //! -//! * `finito-in-mem`: In-memory implementation of state machines -//! that do not need to live longer than an application using -//! standard library concurrency primitives. +//! * `finito-in-mem`: In-memory implementation of state machines that do not +//! need to live longer than an application using standard library +//! concurrency primitives. //! -//! * `finito-postgres`: Postgres-backed, persistent implementation -//! of state machines that, well, do need to live longer. Uses -//! Postgres for concurrency synchronisation, so keep that in -//! mind. +//! * `finito-postgres`: Postgres-backed, persistent implementation of state +//! machines that, well, do need to live longer. Uses Postgres for +//! concurrency synchronisation, so keep that in mind. //! //! Which should cover most use-cases. Okay, enough prose, lets dive //! in. @@ -110,8 +109,8 @@ extern crate serde; -use serde::Serialize; use serde::de::DeserializeOwned; +use serde::Serialize; use std::fmt::Debug; use std::mem; @@ -120,7 +119,10 @@ use std::mem; /// /// This trait is used to implement transition logic and to "tie the /// room together", with the room being our triplet of types. -pub trait FSM where Self: Sized { +pub trait FSM +where + Self: Sized, +{ /// A human-readable string uniquely describing what this FSM /// models. This is used in log messages, database tables and /// various other things throughout Finito. @@ -166,7 +168,7 @@ pub trait FSM where Self: Sized { /// `act` interprets and executes FSM actions. This is the only /// part of an FSM in which side-effects are allowed. - fn act(Self::Action, &Self::State) -> Result, Self::Error>; + fn act(action: Self::Action, state: &Self::State) -> Result, Self::Error>; } /// This function is the primary function used to advance a state @@ -223,11 +225,13 @@ pub trait FSMBackend { /// Insert a new state-machine into the backend's storage and /// return its newly allocated key. fn insert_machine(&self, initial: F) -> Result - where F: FSM + Serialize + DeserializeOwned; + where + F: FSM + Serialize + DeserializeOwned; /// Retrieve the current state of an FSM by its key. fn get_machine(&self, key: Self::Key) -> Result - where F: FSM + Serialize + DeserializeOwned; + where + F: FSM + Serialize + DeserializeOwned; /// Advance a state machine by applying an event and persisting it /// as well as any resulting actions. @@ -236,8 +240,9 @@ pub trait FSMBackend { /// on the backend used. Please consult the backend's /// documentation for details. fn advance<'a, F: FSM>(&'a self, key: Self::Key, event: F::Event) -> Result - where F: FSM + Serialize + DeserializeOwned, - F::State: From<&'a S>, - F::Event: Serialize + DeserializeOwned, - F::Action: Serialize + DeserializeOwned; + where + F: FSM + Serialize + DeserializeOwned, + F::State: From<&'a S>, + F::Event: Serialize + DeserializeOwned, + F::Action: Serialize + DeserializeOwned; } -- cgit 1.4.1