namespace AyCode.Services.SignalRs; /// /// Controls how the binary protocol serializes and transports data over the network. /// /// Bytes: Serialize via ArrayBinaryOutput → single contiguous byte[], /// written to the pipe as a raw blob. Deserialize via SequenceReader.ToArray() → /// ArrayBinaryInput (single buffer, TryAdvanceSegment always false → JIT-eliminated). /// Fastest individual ser/deser, no zerocopy, no pipeline overlap. /// /// /// Segment: Serialize via BufferWriterBinaryOutput directly to the PipeWriter, /// chunk-by-chunk with a single Flush at the end. Deserialize via SequenceBinaryInput /// from multi-segment ReadOnlySequence<byte> (lazy TryGet iteration, cross-boundary scratch). /// Zerocopy write, but no pipeline overlap. /// /// /// AsyncSegment: Serialize via AsyncPipeWriterOutput directly to the PipeWriter, /// per-chunk FlushAsync sends data to the network during serialization using self-describing /// chunked framing: each chunk is [201][UINT16 size][data], end signal is [202]. /// Deserialize via PipeReaderBinaryInput from internal Pipe with on-demand ReadAsync /// (background Task processes chunks as they arrive). Zerocopy write + pipeline parallelism /// (ser/network/deser overlap), highest roundtrip potential for large payloads. /// Max chunk data size: 65535 bytes (UINT16). /// /// public enum BinaryProtocolMode { /// /// ArrayBinaryOutput → byte[] → pipe. Deser: ToArray() → ArrayBinaryInput. /// Fastest ser/deser, no zerocopy, no pipeline overlap. /// Bytes = 0, /// /// BufferWriterBinaryOutput → PipeWriter, single Flush at end. Deser: SequenceBinaryInput (multi-segment). /// Zerocopy write, no pipeline overlap. /// Segment = 1, /// /// AsyncPipeWriterOutput → PipeWriter, per-chunk FlushAsync with self-describing chunked framing. /// Each chunk (including the last) is sent as [201][UINT16 size][data]; end signal is [202]. /// Deser: PipeReaderBinaryInput from internal Pipe (on-demand ReadAsync, background Task). /// Zerocopy write + pipeline parallelism (ser/network/deser overlap). /// Max chunk data size: 65535 bytes (UINT16). /// AsyncSegment = 2, }