pub trait Transition<TFrom, TTo> {
type F = fn();
}Expand description
Declares that a definition crate permits TFrom -> TTo.
The definition crate owns the stand-in and state types. Rust’s orphan rules
therefore prevent an implementation crate from adding transitions. This
trait is the graph edge only; it does not define what happens to the
runtime value during the edge. Runtime effects are supplied later by
StateMachineImpl!.
F is the required positional call signature for the transition. A
zero-argument transition can use the default fn(). A transition that must
be called with a String declares type F = fn(String).
pub struct ConnectionStandin;
pub struct Connected;
pub struct Authenticated;
impl magicstatemachines::Transition<Connected, Authenticated> for ConnectionStandin {
type F = fn(String);
}With the definition macro, the same declaration is usually written as:
magicstatemachines::StateMachineDefinition! {
for ConnectionStandin;
pub Initial: Connected;
transition Connected => Authenticated(user: String);
}The name user is documentation for the contract and for the matching
implementation body. The actual transition call remains positional:
transition!(self, user.into()).
Provided Associated Types§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".