def encode
import bend-kit-websocket@0.4.0.0/websocket.bend as Websocketimport Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
373# A frame's octets. A client passes Some{mask key} and the payload goes masked;
374# None sends it clear, as a server does. Fails on a frame that breaks rules.
375def encode(f: Frame<Bytes.Bytes>, key: Maybe<&2, U32>) -> Result<&1, &1, U32 & String, Bytes.Bytes>:
376 Frame{+fin, +op, payload} = f
377 Bytes.Bytes{+len, buf} = payload
378 encode.checked(rules(fin, 0, op, len), fin, op, key, Bytes.Bytes{len, buf})