transport-spawn
Source: crates/lvcs-net/src/transport/shell.rs.
/// Run the transport for `swarm` (from `build_swarm`) on the current tokio
/// runtime with `config`, listening on every IPv4 interface (TCP and QUIC,
/// ports the system picks) when `config.listen` is empty. The transport
/// actor is stepped inline and journaled through `journal` (decisions 222
/// and 286).
///
/// Events go to `events` in order, and the shell waits while `events` is
/// full, so the receiver must keep draining it. Commands go through the
/// returned handle (`TransportHandle::send`, which waits while the command
/// queue is full and returns the command when the transport has stopped);
/// the transport stops once every handle is dropped, and the task then
/// ends. Owner: `M3.transport`; the daemon (`M3.daemon`) runs it.
///
/// # Errors
///
/// [`NetError`] when a configured address does not parse, or the sync
/// protocol is already accepted.
pub fn spawn<P, J>(
swarm: Swarm<Behaviour>,
config: &TransportConfig,
events: mpsc::Sender<TransportEvent>,
journal: TransportJournal<P, J>,
) -> Result<(TransportHandle, JoinHandle<()>), NetError>
where
P: sml::Policies + 'static,
TransportActor<P>: Send,
J: FnMut(TransportEvents, &mut TransportActor<P>) + Send + 'static,