pub enum Message<'a> {
Push(Expression<'a>),
Pull(Id),
Resolve {
export_id: Id,
value: Expression<'a>,
},
Reject {
export_id: Id,
value: Expression<'a>,
},
Release {
import_id: Id,
refcount: u64,
},
Abort(Expression<'a>),
}Expand description
A top-level message in the Cap’n Web protocol
Variants§
Push(Expression<'a>)
Asks the recipient to evaluate the given expression
The expression is implicitly assigned the next sequential import ID (in the positive direction). The recipient will evaluate the expression, delivering any calls therein to the application. The final result can be pulled, or used in promise pipelining.
Pull(Id)
Signals that the sender would like to receive a “resolve” message for the resolution of the given import, which must refer to a promise.
This is normally only used for imports created by a “push”, as exported promises are pulled automatically.
Resolve
Instructs the recipient to evaluate the given expression and use it as the resolution of the given promise export
Fields
value: Expression<'a>The value to resolve the promise to
Reject
Instructs the recipient to evaluate the given expression and then use it to reject the given promise export.
The expression is not permitted to contain stubs. It typically evaluates to an Error,
although technically JavaScript does not require that thrown values are Errors.
Fields
value: Expression<'a>The value to reject the promise with
Usually evaluates to an Expression::Error.
Release
Instructs the recipient to release the given entry in the import table, disposing whatever it is connected to.
If the import is a promise, the recipient is no longer obliged to send a “resolve” message for it, though it is still permitted to do so.
Fields
refcount: u64The total number of times this import ID has been “introduced”
i.e. the number of times it has been the subject of an “export” or “promise” expression, plus 1 if it was created by a “push”. The refcount must be sent to avoid a race condition if the receiving side has recently exported the same ID again. The exporter remembers how many times they have exported this ID, decrementing it by the refcount of any release messages received, and only actually releases the ID when this count reaches zero.
Abort(Expression<'a>)
Indicates that the sender has experienced an error causing it to terminate the session
The expression evaluates to the error which caused the abort. No further messages will be sent nor received.