# JournalBufferReader Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalbufferreader/)

## IsNext(ReadOnlySpan&lt;byte&gt;, bool) {#isnext-system-readonlyspan-byte-bool-9f709ce3}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalbufferreader/methods/isnext-system-readonlyspan-byte-bool-9f709ce3/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/JournalBufferReader.cs#L114)

```csharp
public bool IsNext(ReadOnlySpan<byte> next, bool advancePast = false)
```

Checks whether the next bytes match `next`.

### Parameters

- `next` (`ReadOnlySpan<byte>`): The bytes to compare to the next bytes.
- `advancePast` (`bool`): Whether to advance past the bytes if they match.

### Returns

`true` if the next bytes match; otherwise, `false`.

## Peek(int) {#peek-int-9080652a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalbufferreader/methods/peek-int-9080652a/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/JournalBufferReader.cs#L94)

```csharp
public ArcBuffer Peek(int count)
```

Returns a pinned slice of the provided length without reading the data.

### Parameters

- `count` (`int`): The number of bytes to read.

### Returns

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

## Peek(int, Span&lt;byte&gt;) {#peek-int-system-span-byte-81bba406}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalbufferreader/methods/peek-int-system-span-byte-81bba406/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/JournalBufferReader.cs#L44-L57)

```csharp
public ReadOnlySpan<byte> Peek(int count, Span<byte> destination)
```

Gets a span containing the next `count` bytes without reading them.

### Parameters

- `count` (`int`): The number of bytes to read.
- `destination` (`Span<byte>`): Temporary storage used if the requested bytes are not contiguous.

### Returns

A span containing the requested bytes. The returned span must not be retained after the consumer returns.

## Read(Span&lt;byte&gt;) {#read-system-span-byte-7c0c4895}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalbufferreader/methods/read-system-span-byte-7c0c4895/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/JournalBufferReader.cs#L120)

```csharp
public void Read(Span<byte> destination)
```

Copies the next bytes into `destination` and reads them.

### Parameters

- `destination` (`Span<byte>`): The destination to copy to.

## Skip(int) {#skip-int-0e04763e}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalbufferreader/methods/skip-int-0e04763e/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/JournalBufferReader.cs#L142)

```csharp
public void Skip(int count)
```

Skips the next `count` bytes.

### Parameters

- `count` (`int`): The number of bytes to skip.

## ToArray {#toarray-1bacc6ef}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalbufferreader/methods/toarray-1bacc6ef/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/JournalBufferReader.cs#L82-L84)

```csharp
public byte[] ToArray()
```

Copies the remaining bytes into a new array without reading them.

### Returns

A byte array containing the remaining bytes.

## TryPeek(Span&lt;byte&gt;) {#trypeek-system-span-byte-eb64f705}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalbufferreader/methods/trypeek-system-span-byte-eb64f705/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/JournalBufferReader.cs#L67-L73)

```csharp
public bool TryPeek(Span<byte> destination)
```

Attempts to copy the next bytes into `destination` without reading them.

### Parameters

- `destination` (`Span<byte>`): The destination to copy to.

### Returns

`true` if enough bytes were available; otherwise, `false`.

## TryRead(Span&lt;byte&gt;) {#tryread-system-span-byte-c1b675ca}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalbufferreader/methods/tryread-system-span-byte-c1b675ca/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/JournalBufferReader.cs#L129-L135)

```csharp
public bool TryRead(Span<byte> destination)
```

Attempts to copy the next bytes into `destination` and read them.

### Parameters

- `destination` (`Span<byte>`): The destination to copy to.

### Returns

`true` if enough bytes were available; otherwise, `false`.

## TryReadTo(ArcBuffer, byte, bool) {#tryreadto-out-orleans-serialization-buffers-arcbuffer-byte-bool-5f3872e6}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalbufferreader/methods/tryreadto-out-orleans-serialization-buffers-arcbuffer-byte-bool-5f3872e6/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/JournalBufferReader.cs#L106)

```csharp
public bool TryReadTo(out ArcBuffer slice, byte delimiter, bool advancePastDelimiter = true)
```

Reads bytes until `delimiter` is found.

### Parameters

- `slice` (`ArcBuffer`): The pinned bytes before the delimiter, if it was found. The caller owns the returned buffer and must dispose it.
- `delimiter` (`byte`): The delimiter to search for.
- `advancePastDelimiter` (`bool`): Whether to advance past the delimiter when it is found.

### Returns

`true` if the delimiter was found; otherwise, `false`.

## TrySkip(int) {#tryskip-int-4a24019b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.journalbufferreader/methods/tryskip-int-4a24019b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Journaling/JournalBufferReader.cs#L151-L158)

```csharp
public bool TrySkip(int count)
```

Attempts to skip the next `count` bytes.

### Parameters

- `count` (`int`): The number of bytes to skip.

### Returns

`true` if enough bytes were available; otherwise, `false`.
