1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! The wire contract of `persistent_connect`/`persistent_receive` — the
//! entrypoints a `kind = "chatops"` plugin implements when it declares
//! `scopes.persistent_connection`, the Mattermost/Zulip/Discord-shaped
//! counterpart to the ordinary webhook-delivered `chatops_receive` (see
//! `extwasm.Scopes.PersistentConnection`'s manifest requirement). Register
//! them through the same [`crate::Registry::chatops_op`]/`chatops_ops:`
//! block [`crate::chatops`]'s trio uses — at the wire level this is still
//! "the host calls one of my ops and decodes the answer directly with no
//! `Outcome` wrapper."
//!
//! These types are a field-for-field mirror of
//! internal/extwasm/adapter.go's Persistent* types. Parity is pinned from
//! the Go side by internal/extwasm/sdkcontract_test.go.
//!
//! # The two transports
//!
//! `transport = "long_poll"` needs no [`crate::ws_send`] at all: your
//! `persistent_receive` handler makes its own blocking call via
//! [`crate::http_fetch`]/[`crate::oauth_fetch`] (a long-poll is just an
//! HTTP request a vendor holds open server-side) and returns whatever it
//! found — the host's only job is calling you back-to-back instead of on
//! a schedule tick. `frame` is always `None` for this transport; there is
//! nothing for the host to hand you.
//!
//! `transport = "websocket"` additionally implements `persistent_connect`
//! (called once when the host dials — push your handshake/identify frame
//! via [`crate::ws_send`] from inside it) and reads `frame` on every
//! `persistent_receive` call, which carries one raw inbound frame's text
//! — decode it however your vendor's protocol shapes it, and push any
//! reply frame (a heartbeat ack, say) via [`crate::ws_send`] again. The
//! host owns the actual socket; you never see a connection handle, only
//! frames.
use Deserialize;
pub use crateReceiveResponse as PersistentReceiveResponse;
/// PersistentConnectRequest is what the host passes to
/// `persistent_connect` — deliberately thin, the same reasoning
/// `ScheduledRunInput` documents: this call exists so you can push a
/// handshake frame via [`crate::ws_send`], and `occurred_at` (RFC 3339)
/// is the one useful thing to pass, because a freestanding wasm guest has
/// no clock of its own.
/// PersistentConnectResult is the exact return type `persistent_connect`
/// must have — a bare acknowledgement; the host discards the success
/// payload.
pub type PersistentConnectResult = ;
/// PersistentReceiveRequest is what the host passes to
/// `persistent_receive`. `frame` is `None` for `transport = "long_poll"`
/// (your handler makes its own blocking call instead of being handed
/// one) and `Some(text)` for `transport = "websocket"` — the raw inbound
/// frame the host just read off the socket it holds for you.
/// PersistentReceiveResult is the exact return type `persistent_receive`
/// must have — the identical shape `chatops_receive` answers with, so a
/// plugin implementing both transports (or migrating from one to the
/// other) reuses the same note-building code either way.
pub type PersistentReceiveResult = ;