# ArcBufferWriter Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/)

## AdvanceReader(int) {#advancereader-int-05ff4c91}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/advancereader-int-05ff4c91/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L638-L668)

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

Advances the reader by the specified number of bytes.

### Parameters

- `count` (`int`): The number of bytes to advance the reader.

## AdvanceWriter(int) {#advancewriter-int-4d91b671}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/advancewriter-int-4d91b671/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L123-L147)

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

Advances the writer by the specified number of bytes.

### Parameters

- `count` (`int`): The numbers of bytes to advance the writer by.

## AppendPinned(ArcBuffer) {#appendpinned-orleans-serialization-buffers-arcbuffer-8f72ed82}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/appendpinned-orleans-serialization-buffers-arcbuffer-8f72ed82/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L522-L551)

```csharp
public void AppendPinned(ArcBuffer input)
```

Appends the pages referenced by `input` directly to this writer by pinning them.

### Parameters

- `input` (`ArcBuffer`): The buffer to append.

## ConsumeSlice(int) {#consumeslice-int-5aacb0b0}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/consumeslice-int-5aacb0b0/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L622-L629)

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

Consumes a slice of the provided length.

### Parameters

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

### Returns

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

## Dispose {#dispose-61964c1b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/dispose-61964c1b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L266-L273)

```csharp
public void Dispose()
```

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

## GetMemory(int) {#getmemory-int-9fba260c}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/getmemory-int-9fba260c/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L279-L287)

```csharp
public Memory<byte> GetMemory(int sizeHint = 0)
```

Returns a `System.Memory-1` to write to that is at least the requested size (specified by `sizeHint`).

### Parameters

- `sizeHint` (`int`): The minimum length of the returned `System.Memory-1`. If 0, a non-empty buffer is returned.

### Returns

A `System.Memory-1` of at least the size `sizeHint`. If `sizeHint` is 0, returns a non-empty buffer.

### Exceptions

- `System.OutOfMemoryException`: The requested buffer size is not available.

## GetSpan(int) {#getspan-int-b7e8cc58}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/getspan-int-b7e8cc58/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L294-L302)

```csharp
public Span<byte> GetSpan(int sizeHint = 0)
```

Returns a `System.Span-1` to write to that is at least the requested size (specified by `sizeHint`).

### Parameters

- `sizeHint` (`int`): The minimum length of the returned `System.Span-1`. If 0, a non-empty buffer is returned.

### Returns

A `System.Span-1` of at least the size `sizeHint`. If `sizeHint` is 0, returns a non-empty buffer.

## Peek(Span&lt;byte&gt;) {#peek-in-system-span-byte-fee85468}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/peek-in-system-span-byte-fee85468/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L312-L323)

```csharp
public ReadOnlySpan<byte> Peek(scoped in Span<byte> destination)
```

Attempts to read the provided number of bytes from the buffer.

### Parameters

- `destination` (`Span<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 at least the requested length if the data is available.

## Peek(Span&lt;byte&gt;) {#peek-system-span-byte-55756587}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/peek-system-span-byte-55756587/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L330-L349)

```csharp
public int Peek(Span<byte> output)
```

Copies the contents of this writer to a span.

### Parameters

- `output` (`Span<byte>`)

## PeekSlice(int) {#peekslice-int-d751cafb}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/peekslice-int-d751cafb/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L596-L610)

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

Returns a pinned slice of the provided length without marking the data referred to it as consumed.

### Parameters

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

### Returns

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

## ReplenishBuffers(List&lt;ArraySegment&lt;byte&gt;&gt;) {#replenishbuffers-system-collections-generic-list-system-arraysegment-byte-760c8180}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/replenishbuffers-system-collections-generic-list-system-arraysegment-byte-760c8180/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L92-L110)

```csharp
public void ReplenishBuffers(List<ArraySegment<byte>> buffers)
```

Adds additional buffers to the destination list until the list has reached its capacity.

### Parameters

- `buffers` (`List<ArraySegment<byte>>`): The destination to add buffers to.

## Reset {#reset-d7b95a79}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/reset-d7b95a79/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L253-L261)

```csharp
public void Reset()
```

Resets this instance, returning all memory.

## Truncate(int) {#truncate-int-803f5b3f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/truncate-int-803f5b3f/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L207-L246)

```csharp
public void Truncate(int length)
```

Truncates this buffer to the specified unconsumed length.

### Parameters

- `length` (`int`): The new length of the unconsumed bytes.

## Write(ReadOnlySequence&lt;byte&gt;) {#write-system-buffers-readonlysequence-byte-8a5bf58c}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/write-system-buffers-readonlysequence-byte-8a5bf58c/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L481-L487)

```csharp
public void Write(ReadOnlySequence<byte> input)
```

Writes the provided sequence to this buffer.

### Parameters

- `input` (`ReadOnlySequence<byte>`): The data to write.

## Write(ReadOnlySpan&lt;byte&gt;) {#write-system-readonlyspan-byte-f5a31400}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/write-system-readonlyspan-byte-f5a31400/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L496-L510)

```csharp
public void Write(ReadOnlySpan<byte> value)
```

Writes the provided value to this buffer.

### Parameters

- `value` (`ReadOnlySpan<byte>`): The data to write.

## WriteAt(int, ReadOnlySpan&lt;byte&gt;) {#writeat-int-system-readonlyspan-byte-20c76fd1}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.arcbufferwriter/methods/writeat-int-system-readonlyspan-byte-20c76fd1/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/ArcBufferWriter.cs#L156-L199)

```csharp
public void WriteAt(int offset, ReadOnlySpan<byte> value)
```

Overwrites bytes which have already been written to this buffer without changing the writer position.

### Parameters

- `offset` (`int`): The offset into the unconsumed bytes at which to start writing.
- `value` (`ReadOnlySpan<byte>`): The bytes to write.
