Skip to main content

open_stream_direct

Function open_stream_direct 

Source
pub async fn open_stream_direct(
    resolve_via: &mut Session,
    id: &KeyPair,
    realm: [u8; 32],
    procedure: &str,
    mode: StreamMode,
    args: Value,
    deadline_ms: i128,
    timeout: Duration,
) -> Result<(Session, StreamHandle), OpenStreamDirectError>
Expand description

Resolves procedure’s provider via direct-dial (through resolve_via, used only to query the DHT) and opens a stream there, in one hop, in a SEPARATE connection from resolve_via — the streaming-RPC counterpart to call. The provider must have advertised via advertise_direct: streaming’s provider side (macula_streamer.erl) shares the identical procedure_advertisement mechanism RPC uses (confirmed against macula_streamer.erl/macula_stream_sink.erl’s own advertise_direct/ start_link_direct — both are macula_response:advertise_direct/ macula_direct_dial:call_stream under the hood, nothing stream-specific added), so no separate stream-shaped advertise function exists or is needed.

The caller owns the returned Session (and must close it once the stream and any other work on it is done) alongside the StreamHandle itself, since — unlike call, which owns its dial for exactly one request/reply — a stream outlives the single function call that opens it.