Message

Enum Message 

Source
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

§export_id: Id

The ID of the export to resolve

§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

§export_id: Id

The ID of the export to reject

§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

§import_id: Id

The ID of the import to release

§refcount: u64

The 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.

Trait Implementations§

Source§

impl<'a> Debug for Message<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Message<'de>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Message<'_>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Message<'a>

§

impl<'a> RefUnwindSafe for Message<'a>

§

impl<'a> Send for Message<'a>

§

impl<'a> Sync for Message<'a>

§

impl<'a> Unpin for Message<'a>

§

impl<'a> UnwindSafe for Message<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.