public static bool TryParse(MemoryCursor cursor, ExtensionType type, Range range, out MemoryBuffer buffer)
        {
            buffer = new MemoryBuffer();

            if (!ExtensionType.TrySlice(cursor, type))
            {
                return(false);
            }

            buffer = ExtensionVectorLength.Slice(cursor, range);

            return(true);
        }
Exemplo n.º 2
0
        public static bool TryParse(ReadOnlyMemory <byte> bytes, out AlpnExtension result, out ReadOnlyMemory <byte> remainings)
        {
            result     = new AlpnExtension();
            remainings = bytes;

            var type = ExtensionType.Parse(bytes, out var afterTypeBytes);

            if (type != ExtensionType.ApplicationLayerProtocolNegotiation)
            {
                return(false);
            }

            var payload = ExtensionVectorLength.Slice(afterTypeBytes, 2..ushort.MaxValue, out remainings);

            result = new AlpnExtension(payload);

            return(true);
        }
        public static ExtensionVectorLength.CursorWritingContext StartWriting(MemoryCursor cursor, ExtensionType type, Range range)
        {
            type.WriteBytes(cursor);

            return(ExtensionVectorLength.StartWriting(cursor, range));
        }