lightyear_crossbeam 0.30.1

IO primitives for the lightyear networking library
Documentation

In-process Crossbeam channel transport for Lightyear.

This crate provides [CrossbeamIo], a transport implementation backed by crossbeam-channel. It is primarily intended for tests, local examples, and in-process simulations where deterministic setup and low overhead are more useful than real network IO. It still uses Lightyear's normal [Link] buffers and lifecycle markers, so code above the transport layer can be exercised without special cases.

Connection layer

[CrossbeamPlugin] is a pure transport: it inserts [Linked] once [LinkStart] is triggered but does not drive the Connected state. Pair it with a connection plugin to obtain a full peer connection. For handshake-less use, pair it with lightyear_raw_connection::client::RawConnectionPlugin and/or lightyear_raw_connection::server::RawConnectionPlugin and mark entities with RawClient / RawServer so that [Linked] implies Connected. For authenticated use, pair it with lightyear_netcode.

Spawning crossbeam entities

Always trigger [LinkStart] to bring a [CrossbeamIo] entity online, rather than inserting [Linked] directly. [CrossbeamPlugin] gates its link observer on With<CrossbeamIo>, so by the time [Linked] is inserted the required Aeronet-compatible LocalAddr and PeerAddr components are also present. Connection-layer Add<Linked> observers can then construct their local and remote IDs reliably.

// Server-side mirror entity (one per connecting crossbeam client):
let mirror = commands
    .spawn((LinkOf { server }, Link::default(), io))
    .id();
commands.trigger(LinkStart { entity: mirror });

// Client-side connection entity:
let client = commands
    .spawn((Client, RawClient, Link::default(), io))
    .id();
commands.trigger(Connect { entity: client });  // Connect → LinkStart internally