Hare API reference
bonsai
Index
Types
type action = (action_event_received | action_context_changed);
type action_context_changed = struct {
context_elements: []context_element,
};
type action_event_received = struct {
event_name: event_name,
};
type context_element = (str, str);
type event_name = str;
type state_machine = struct {
all_transitions: []*transition,
available_transitions: []*transition,
context_elements: []context_element,
waiting_transition_delay: (*transition_delay | void),
};
type transition = struct {
_type: str,
transitions: []*transition,
};
type transition_context = struct {
transition,
context_elements: []context_element,
};
type transition_delay = struct {
transition,
delay_duration: int,
};
type transition_event = struct {
transition,
event_name: event_name,
};
type transition_exec = struct {
transition,
command: []str,
};
Errors
type bad_syntax = !(unsupported_type | first_isnt_array | transition_isnt_object | missing_transition_type | missing_contexts | missing_event_name | missing_delay_duration | missing_command | type_isnt_str | command_isnt_array | contexts_isnt_object | context_value_isnt_str | transitions_isnt_array | delay_duration_isnt_int | event_name_isnt_str | command_argument_isnt_str);
type command_argument_isnt_str = !void;
type command_isnt_array = !void;
type context_value_isnt_str = !void;
type contexts_isnt_object = !void;
type delay_duration_isnt_int = !void;
type error = !bad_syntax;
type event_name_isnt_str = !void;
type first_isnt_array = !void;
type missing_command = !void;
type missing_contexts = !void;
type missing_delay_duration = !void;
type missing_event_name = !void;
type missing_transition_type = !void;
type transition_isnt_object = !void;
type transitions_isnt_array = !void;
type type_isnt_str = !void;
type unsupported_type = !void;
Functions
fn context_element_str(literal: str) (context_element | nomem);
fn context_elements_match_all(context_elements: []context_element, to_match_context_elements: []context_element) bool;
fn context_elements_set_key_if_present(context_elements: []context_element, key: str, value: str) (bool | nomem);
fn finish_context_element(elem: context_element) void;
fn finish_context_elements(elems: []context_element) void;
fn finish_state(state: *state_machine) void;
fn finish_transition(transition: *transition) void;
fn finish_transitions(transitions: []*transition) void;
fn load_transitions(source: io::handle) ([]*transition | json::error | error | nomem);
fn state_forward(state: *state_machine, act: action) (bool | nomem);
fn str_context_element(context_element: context_element) (str | nomem);
fn strerror(err: error) str;
fn trigger_transition_delay_expired(state: *state_machine) void;
fn write_transitions(handle: io::handle, transitions: []*transition) (void | io::error);
Types
type action
Show undocumented member
type action = (action_event_received | action_context_changed);
type action_context_changed
Show undocumented member
type action_context_changed = struct {
context_elements: []context_element,
};
type action_event_received
Show undocumented member
type action_event_received = struct {
event_name: event_name,
};
type context_element
Show undocumented member
type context_element = (str, str);
type event_name
Show undocumented member
type event_name = str;
type state_machine
Show undocumented member
type state_machine = struct {
all_transitions: []*transition,
available_transitions: []*transition,
context_elements: []context_element,
waiting_transition_delay: (*transition_delay | void),
};
type transition
Show undocumented member
type transition = struct {
_type: str,
transitions: []*transition,
};
type transition_context
Show undocumented member
type transition_context = struct {
transition,
context_elements: []context_element,
};
type transition_delay
Show undocumented member
type transition_delay = struct {
transition,
delay_duration: int,
};
type transition_event
Show undocumented member
type transition_event = struct {
transition,
event_name: event_name,
};
type transition_exec
Show undocumented member
type transition_exec = struct {
transition,
command: []str,
};
Errors
type bad_syntax
Show undocumented member
type bad_syntax = !(unsupported_type | first_isnt_array | transition_isnt_object | missing_transition_type | missing_contexts | missing_event_name | missing_delay_duration | missing_command | type_isnt_str | command_isnt_array | contexts_isnt_object | context_value_isnt_str | transitions_isnt_array | delay_duration_isnt_int | event_name_isnt_str | command_argument_isnt_str);
type command_argument_isnt_str
Show undocumented member
type command_argument_isnt_str = !void;
type command_isnt_array
Show undocumented member
type command_isnt_array = !void;
type context_value_isnt_str
Show undocumented member
type context_value_isnt_str = !void;
type contexts_isnt_object
Show undocumented member
type contexts_isnt_object = !void;
type delay_duration_isnt_int
Show undocumented member
type delay_duration_isnt_int = !void;
type error
Show undocumented member
type error = !bad_syntax;
type event_name_isnt_str
Show undocumented member
type event_name_isnt_str = !void;
type first_isnt_array
Show undocumented member
type first_isnt_array = !void;
type missing_command
Show undocumented member
type missing_command = !void;
type missing_contexts
Show undocumented member
type missing_contexts = !void;
type missing_delay_duration
Show undocumented member
type missing_delay_duration = !void;
type missing_event_name
Show undocumented member
type missing_event_name = !void;
type missing_transition_type
Show undocumented member
type missing_transition_type = !void;
type transition_isnt_object
Show undocumented member
type transition_isnt_object = !void;
type transitions_isnt_array
Show undocumented member
type transitions_isnt_array = !void;
type type_isnt_str
Show undocumented member
type type_isnt_str = !void;
type unsupported_type
Show undocumented member
type unsupported_type = !void;
Functions
fn context_element_str
Show undocumented member
fn context_element_str(literal: str) (context_element | nomem);
fn context_elements_match_all
Show undocumented member
fn context_elements_match_all(context_elements: []context_element, to_match_context_elements: []context_element) bool;
fn context_elements_set_key_if_present
Show undocumented member
fn context_elements_set_key_if_present(context_elements: []context_element, key: str, value: str) (bool | nomem);
fn finish_context_element
Show undocumented member
fn finish_context_element(elem: context_element) void;
fn finish_context_elements
Show undocumented member
fn finish_context_elements(elems: []context_element) void;
fn finish_state
Show undocumented member
fn finish_state(state: *state_machine) void;
fn finish_transition
Show undocumented member
fn finish_transition(transition: *transition) void;
fn finish_transitions
Show undocumented member
fn finish_transitions(transitions: []*transition) void;
fn load_transitions
Show undocumented member
fn load_transitions(source: io::handle) ([]*transition | json::error | error | nomem);
fn state_forward
Show undocumented member
fn state_forward(state: *state_machine, act: action) (bool | nomem);
fn str_context_element
Show undocumented member
fn str_context_element(context_element: context_element) (str | nomem);
fn strerror
Show undocumented member
fn strerror(err: error) str;
fn trigger_transition_delay_expired
Show undocumented member
fn trigger_transition_delay_expired(state: *state_machine) void;
fn write_transitions
Show undocumented member
fn write_transitions(handle: io::handle, transitions: []*transition) (void | io::error);