public static FrameType Peek(MemoryCursor cursor) { var bytes = cursor.PeekEnd(); var value = VariableLengthEncoding.Decode(bytes.Span, out _); return(new FrameType(value)); }
public static StreamId Parse(ReadOnlyMemory <byte> bytes, out ReadOnlyMemory <byte> remainings) { var id = VariableLengthEncoding.Decode(bytes.Span, out var decodedLength); remainings = bytes.Slice(decodedLength); return(new StreamId(id)); }
public static Error ParseTransport(ReadOnlyMemory <byte> bytes, out ReadOnlyMemory <byte> remainings) { var code = VariableLengthEncoding.Decode(bytes.Span, out var decodedLength); remainings = bytes.Slice(decodedLength); return(new Error(code, true, false)); }
public static FrameType Parse(ReadOnlyMemory <byte> bytes, out ReadOnlyMemory <byte> remainings) { var code = VariableLengthEncoding.Decode(bytes.Span, out var decodedLength); remainings = bytes.Slice(decodedLength); return(new FrameType(code)); }
public void ReadValue_ResultIsExpected(string bytes, ulong expectedValue, int expectedLength) { //Arrange //Act var resultValue = VariableLengthEncoding.Decode(Utils.ParseHexString(bytes), out var resultLength); //Assert Assert.Equal(expectedValue, resultValue); Assert.Equal(expectedLength, resultLength); }
private int ReadLength() { var length = VariableLengthEncoding.Decode(remainings.Span, out var decodedLength); if (length > int.MaxValue) { throw new EncodingException(); } remainings = remainings.Slice(decodedLength); return((int)length); }
public static bool TrySlice(MemoryCursor cursor, FrameType expected) { var bytes = cursor.PeekEnd(); var type = VariableLengthEncoding.Decode(bytes.Span, out var decodedLength); if (type != expected.type) { return(false); } cursor.Move(decodedLength); return(true); }
public static bool TrySlice(MemoryCursor cursor, TransportParameterType expected) { var bytes = cursor.PeekEnd(); var id = VariableLengthEncoding.Decode(bytes.Span, out var decodedLength); if (id != expected.id) { return(false); } cursor.Move(decodedLength); return(true); }