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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! RPC method registration: plugins expose methods that PHP workers can invoke
//! on the master in-process (via the `folk_call()` native function).
//!
//! Two shapes of method exist:
//!
//! * **Unary** ([`RpcRegistrar`]) — one request `Bytes` → one response `Bytes`,
//! driven by the synchronous `folk_call` bridge.
//! * **Streaming** ([`StreamRegistrar`], phase 88b) — one open → a stream of
//! messages in either or both directions, driven by the handle-based blocking
//! bridge (`folk_stream_open/recv/send/close`). The handler returns a
//! [`StreamConn`] the bridge blocking-drains one message at a time.
use Future;
use Pin;
use Arc;
use Result;
use async_trait;
use Bytes;
use Stream;
/// Static description of an RPC method (advertised at server start; used
/// for introspection / documentation).
/// Boxed future returned by an RPC handler.
pub type BoxFuture<'a, T> = ;
/// Type alias for an RPC handler: takes raw request bytes, returns raw response bytes.
pub type RpcHandler = ;
/// Allows plugins to register RPC method handlers at boot.
///
/// `folk-core` provides the concrete implementation.
// ---------------------------------------------------------------------------
// Streaming (phase 88b)
// ---------------------------------------------------------------------------
/// One inbound message of a stream: raw response `Bytes`, or an error carrying a
/// gRPC-style status the bridge surfaces to PHP as an exception.
pub type StreamItem = ;
/// Boxed inbound message stream. The bridge blocking-drains it one item at a time
/// (`folk_stream_recv` → `Some(bytes)` per item, `None` at end-of-stream).
pub type InboundStream = ;
/// Outbound message channel for client-streaming / bidi: the bridge pushes
/// PHP-sent messages here (`folk_stream_send`), closing it half-closes the send
/// side (`folk_stream_close_send`). `tokio::sync::mpsc` gives natural backpressure.
pub type OutboundSender = Sender;
/// A live stream connection returned by a [`StreamHandler`]. The transport plugin
/// (e.g. `folk-plugin-grpc`) adapts its own stream type (tonic `Streaming`) into
/// this transport-agnostic pair; the bridge in `folk-ext` drives it.
///
/// `#[non_exhaustive]`: construct via [`StreamConn::server_streaming`] /
/// [`StreamConn::duplex`] so future fields (deadlines, trailing metadata) can be
/// added without breaking transport plugins.
/// A streaming handler: given the initial request bytes, opens a [`StreamConn`].
pub type StreamHandler = ;
/// Allows plugins to register streaming method handlers at boot. Additive
/// counterpart to [`RpcRegistrar`]; `folk-core` provides the concrete impl.