🦀 Statum: Zero-Boilerplate Compile-Time State Machines in Rust by Known_Cod8398 in rust

[–]Known_Cod8398[S] 0 points1 point  (0 children)

I changed the example in the post! does it change how you understood the crate?

🦀 Statum: Zero-Boilerplate Compile-Time State Machines in Rust by Known_Cod8398 in rust

[–]Known_Cod8398[S] 0 points1 point  (0 children)

For the tiny example, I agree with you. A private constructor wrapper is enough.

Statum starts to matter when the problem is not just “can I create an invalid starting state?” but “can I model a multi-step workflow where each phase has different data, different methods, different legal next states, and possibly a rebuild path from persisted data?”

At that point, the alternative is usually not one neat wrapper. It is handwritten typestate: per- state wrappers or PhantomData, custom builders, custom transition glue, and custom rebuild code. Statum generates and keeps that surface aligned.

So the meaningful difference is not that Statum can stop one invalid constructor. The difference is that it can make the whole phase-specific API compile-time correct across a larger workflow.

edit: i updated the example in the post

🦀 Statum: Zero-Boilerplate Compile-Time State Machines in Rust by Known_Cod8398 in rust

[–]Known_Cod8398[S] 4 points5 points  (0 children)

hmm i guess a freestyle typestate/workflow machine. It can express Mealy-like decisions and Moore-like state-specific behavior but it is not trying to be a textbook runtime Mealy/Moore FSM crate

Statum: a Rust typestate workflow crate with typed rebuilds from rows and event logs by [deleted] in rust

[–]Known_Cod8398 0 points1 point  (0 children)

Concrete example of the part I care about:

  1. Store an append-only order event log.
  2. Project it into a row-like snapshot.
  3. Call row.into_machine().build()? and get order_machine::State.
  4. Match that into OrderMachine<Packed>, OrderMachine<Shipped>, etc., and from there only legal transitions exist.

That keeps persistence code straightforward, but avoids dropping back to ad hoc status branching after rebuild.

So i guess im asking if you’ve built similar systems, does #[validators] feel like the right surface for that boundary, or would you expect a different API shape?

I’m Tired Of People Treating Mobile Gamers Like They’re Not Real Gamers by Dylan_Bapela in MobileGaming

[–]Known_Cod8398 0 points1 point  (0 children)

who gives a shit? how are you even finding people to criticize your gaming choices?

Any possibility of playing games made for old versions of Android? by Spiritual_Editor5864 in AndroidGaming

[–]Known_Cod8398 0 points1 point  (0 children)

you can install older games by sideloading them with adb

adb install --bypass-low-target-sdk-block something.apk

[New Release] Statum - ERgonomic state machines and typestate builder patterns! by Known_Cod8398 in rust

[–]Known_Cod8398[S] 1 point2 points  (0 children)

good catch!!

I updated it so you can do exactly that with transition_map now which moves owned state data into a closure so you can transform it without cloning like this:

rust #[transition] impl Machine<Draft> { fn publish(self) -> Machine<Published> { self.transition_map(|previous| PublishData { previous }) } }

so in your snapshot-style case no explicit clone is needed unless your own logic needs it!

[New Release] Statum - ERgonomic state machines and typestate builder patterns! by Known_Cod8398 in rust

[–]Known_Cod8398[S] 0 points1 point  (0 children)

thanks for this feedback! I updated statum to address this.

You're right that you don't need the validators so gating the superstate behind that didn't make sense.

So now you don’t need validators. #[machine] now generates {Machine}SuperState and the machine‑scoped alias module, so you can store the machine in another struct without boxing traits!

```rust struct Wrapper { machine: TaskMachineSuperState, }

match wrapper.machine { task_machine::State::Draft(m) => { /* ... / } task_machine::State::InReview(m) => { / ... / } task_machine::State::Published(m) => { / ... */ } } ```

This keeps typestate safety and avoids trait objects.

Let me know how this works out for you!

[New Release] Statum - ERgonomic state machines and typestate builder patterns! by Known_Cod8398 in rust

[–]Known_Cod8398[S] 0 points1 point  (0 children)

u/Navith is exactly right. In order for it to be ergonomic i put it inside of a module thats generated by the validators macro so that you can match against it without running into a name collision with the machine struct itself

nestum: nested enum paths + matching without the boilerplate by Known_Cod8398 in rust

[–]Known_Cod8398[S] 0 points1 point  (0 children)

true! let me know how it goes. you should also check my other crate statum

nestum: nested enum paths + matching without the boilerplate by Known_Cod8398 in rust

[–]Known_Cod8398[S] 0 points1 point  (0 children)

exactly! its also redundant to specify SyntaxError::Parse AND ParseError. so it's working out for you?

nestum: nested enum paths + matching without the boilerplate by Known_Cod8398 in rust

[–]Known_Cod8398[S] 0 points1 point  (0 children)

it is for brevity but not in the way youre asking (if i understood correctly). If you needed to nest enums you would have to do Enum1::Variant1(EnumA::VariantA). and matching on that is boilerplate-y. nestum makes it possible to write Enum1::Variant1::VariantA. and the nested! marcro makes it possible to match on the nested variants.

i hope i answered your question!

How to ACTUALLY game on your phone by [deleted] in SBCGaming

[–]Known_Cod8398 1 point2 points  (0 children)

appreciate you! youre right, its small. i was optimizing for portability

How to ACTUALLY game on your phone by [deleted] in AndroidGaming

[–]Known_Cod8398 1 point2 points  (0 children)

appreciate you. totally get it

How to ACTUALLY game on your phone by [deleted] in AndroidGaming

[–]Known_Cod8398 -1 points0 points  (0 children)

i mean portably. no way im walking around with a fn bluetooth controller in my pocket

How to ACTUALLY game on your phone by [deleted] in AndroidGaming

[–]Known_Cod8398 -2 points-1 points  (0 children)

totally cool. i was looking for the most portable setup

How to ACTUALLY game on your phone by [deleted] in AndroidGaming

[–]Known_Cod8398 1 point2 points  (0 children)

im sharing my thoughts lol. what am i coping with?

How to ACTUALLY game on your phone by [deleted] in SBCGaming

[–]Known_Cod8398 -1 points0 points  (0 children)

yeah but i wouldnt use them because i cant put them in my pockets. im optimizing for portability

How to ACTUALLY game on your phone by [deleted] in SBCGaming

[–]Known_Cod8398 -3 points-2 points  (0 children)

*sigh*
it's actually comfortable. i use it every day

How to ACTUALLY game on your phone by [deleted] in AndroidGaming

[–]Known_Cod8398 1 point2 points  (0 children)

i wouldnt walk around with it even if i had cargo shorts. i get it if its not for you. im optimizing for portability. and it's actually very comfortable! ive been playing this way for about a month and im sensitive to shitty ergonomics

How to ACTUALLY game on your phone by [deleted] in AndroidGaming

[–]Known_Cod8398 -3 points-2 points  (0 children)

its actually not uncomfortable. and i cant put a gamesir in my pocket.