Skip to content
Playground(another site)

bynk.held.query_accessor_on_held_map

Error A key-aware query accessor (.entries/.keys/.values) is used on a held Map[K, Connection] — a held resource is iterated with the broadcast ops (forEach/parTraverse), not a key query.

A held Map[K, Connection] is iterated with the broadcast operations, forEach (one at a time) or parTraverse (in parallel), not with a key query. .entries, .keys and .values would lift the connections out into a query, which the single-owner rules for held values do not allow. To send to every connection, broadcast over the map; to learn who is connected, keep a separate Set of their keys.

Example

conns.keys.collect() // ✗ a held map has no key queries
let _ <- conns.parTraverse((c: Connection[ServerFrame]) => c.send(ServerFrame { text: text })) // ✓ broadcast

In the Book

See also

  • Every code in its category, Other, on the diagnostic index.
  • bynk explain bynk.held.query_accessor_on_held_map shows the same from the installed toolchain, without a network.