pub fn deliver(
state: &State,
send: &Effect,
transport: &dyn Transport,
) -> Result<Delivery, Error>Expand description
Delivers send, a send of URI or SHORT_FORM the driver handed
the host from state: encodes it as the reference encodes it, hands the
request to transport once, and reports a miss to the chart.
send is the Effect::Send or Effect::SendDelayed as the host
was handed it, or, for an invoked child’s send, the Effect::Child
carrying it. A delayed send is delivered at once: the host calls this
when its delay has passed, unless a <cancel> named it first.
The request is a POST to the send’s target. A data that is a map,
the namelist and <param> values or a <content> whose value is a
map, is a form body (application/x-www-form-urlencoded): the event’s
name as _scxmleventname first, then each member in the order the
reference walks a map of up to 32 members (integer keys, then false,
true and undefined, then string keys, each in its own order). No data
sends _scxmleventname alone as a form body. Any other <content> is a
text/plain body, and the event’s name travels as a _scxmleventname
query parameter of the target. Names and values are percent-encoded,
every byte outside letters, digits, -, ., _ and ~, a space as
+. A value is written as text: a string as it is, a number or a
boolean as its literal, null as null, undefined as the empty string,
a list or a map as JSON text. The request carries the content-type
header and the scxml-send-key header, the reference’s dedup key: the
session’s id, the send id, the macrostep, microstep and round, the
content index, the owner and the ordinal, joined by /.
A 2xx response answers Delivery::Delivered. A send with no target,
a transport error, and a response whose status is outside 2xx answer
Delivery::Missed: the miss is reported with
State::report_send_failed, whose new state the delivery carries.
A send with no target whose type the sending session lists in
Options::target_required, as register lists both spellings, is
the exception: the driver raised its error.communication itself, when
the send was made, so it is answered missed with no report and nothing
moved.
Refused, with nothing requested, as State::report_send_failed
refuses an effect that is not a send handed to the host, and with
crate::Error::NotAHandedSend for a send of another type.