Skip to content

ArcBufferReader Methods

Provides reader access to an ArcBufferWriter.

ConsumeSlice(int)

View source
public ArcBuffer ConsumeSlice(int count)
Consumes a slice of the provided length.

Parameters

countint
The number of bytes to consume.

Returns

A pinned buffer representing the consumed data. The caller owns the returned buffer and must dispose it.

IsNext(ReadOnlySpan<byte>, bool)

View source
public bool IsNext(ReadOnlySpan<byte> next, bool advancePast = false)
Checks whether the next bytes match next.

Parameters

nextReadOnlySpan<byte>
The bytes to compare to the next bytes.
advancePastbool
Whether to advance past the bytes if they match.

Returns

true if the next bytes match; otherwise, false.

Peek(Span<byte>)

View source
public ReadOnlySpan<byte> Peek(scoped in Span<byte> destination)
Attempts to read the provided number of bytes from the buffer.

Parameters

destinationSpan<byte>
The destination, which may be used to hold the requested data if the data needs to be copied.

Returns

A span of either zero length, if the data is unavailable, or the requested length if the data is available.

Peek(long)

View source
public byte Peek(long offset)
Peeks at a byte at the specified offset into the unread data.

Parameters

offsetlong
The offset into the unread data.

Returns

The byte at the specified offset.

PeekSlice(int)

View source
public ArcBuffer PeekSlice(int count)
Returns a pinned slice of the provided length without marking the data referred to it as consumed.

Parameters

countint
The number of bytes to consume.

Returns

A pinned slice of unconsumed data. The caller owns the returned buffer and must dispose it.

Skip(int)

View source
public void Skip(int count)
Advances the reader by the specified number of bytes.

Parameters

countint
The number of bytes to advance.

TryReadTo(ArcBuffer, byte, bool)

View source
public bool TryReadTo(out ArcBuffer slice, byte delimiter, bool advancePastDelimiter = true)
Reads bytes until delimiter is found.

Parameters

sliceArcBuffer
The pinned bytes before the delimiter, if it was found. The caller owns the returned buffer and must dispose it.
delimiterbyte
The delimiter to search for.
advancePastDelimiterbool
Whether to advance past the delimiter when it is found.

Returns

true if the delimiter was found; otherwise, false.