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
// Copyright AGNTCY Contributors (https://github.com/agntcy)
// SPDX-License-Identifier: Apache-2.0
//! Runtime-agnostic seams that let the session layer share a single source tree
//! across the native (tokio, multi-threaded) build and the wasm32 browser build.
/// Await the expression on wasm32 (where MLS is async) and evaluate it directly
/// on every other target (where MLS is synchronous).
///
/// The enclosing function must be `async` for the wasm32 branch to compile; all
/// current call sites already live in async session methods.
pub use maybe_await;
/// Spawn a session task, returning a [`tokio::task::JoinHandle`].
///
/// On native targets this is `tokio::spawn` (multi-threaded runtime, requires a
/// `Send` future). On wasm32 the session futures are `!Send` (they await the
/// SubtleCrypto-backed MLS provider) and the runtime is single-threaded, so we
/// use `tokio::task::spawn_local`, which yields the same `JoinHandle` type
/// without the `Send` requirement. Both keep the caller-facing API identical.
pub
pub