pub struct Schema {
pub name: String,
pub version: String,
pub states: Vec<State>,
pub actions: Vec<Action>,
pub arcs: Vec<Arc>,
pub constraints: Vec<Constraint>,
pub events: Vec<Event>,
}Expand description
A complete tokenmodel schema definition.
Fields§
§name: String§version: String§states: Vec<State>§actions: Vec<Action>§arcs: Vec<Arc>§constraints: Vec<Constraint>§events: Vec<Event>Implementations§
Source§impl Schema
impl Schema
Sourcepub fn identity_hash(&self) -> String
pub fn identity_hash(&self) -> String
Computes a structural fingerprint (ignoring name/version).
Sourcepub fn structurally_equal(&self, other: &Schema) -> bool
pub fn structurally_equal(&self, other: &Schema) -> bool
Returns true if two schemas have the same structure.
Source§impl Schema
impl Schema
pub fn new(name: impl Into<String>) -> Self
pub fn add_state(&mut self, st: State) -> &mut Self
pub fn add_token_state( &mut self, id: impl Into<String>, initial: i64, ) -> &mut Self
pub fn add_data_state( &mut self, id: impl Into<String>, typ: impl Into<String>, initial: Option<Value>, exported: bool, ) -> &mut Self
pub fn add_action(&mut self, a: Action) -> &mut Self
pub fn add_arc(&mut self, a: Arc) -> &mut Self
pub fn add_constraint(&mut self, c: Constraint) -> &mut Self
pub fn add_event(&mut self, e: Event) -> &mut Self
pub fn state_by_id(&self, id: &str) -> Option<&State>
pub fn action_by_id(&self, id: &str) -> Option<&Action>
pub fn event_by_id(&self, id: &str) -> Option<&Event>
pub fn action_for_event(&self, event_id: &str) -> Option<&Action>
Sourcepub fn input_arcs(&self, action_id: &str) -> Vec<&Arc>
pub fn input_arcs(&self, action_id: &str) -> Vec<&Arc>
Returns all arcs flowing into an action.
Sourcepub fn output_arcs(&self, action_id: &str) -> Vec<&Arc>
pub fn output_arcs(&self, action_id: &str) -> Vec<&Arc>
Returns all arcs flowing out of an action.
pub fn token_states(&self) -> Vec<&State>
pub fn data_states(&self) -> Vec<&State>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more