Development · Native API migration preview · Coverage validation in progress Published release →

API Browser

Method

Drain

abstract virtual func Drain(output: Slice<byte>) -> Result<EncoderProgress, EncodingError>

Declaring type: Encoder
Module: System.Text
Assembly: System.Runtime.dll
Source file: Encoder.rvn

Defined by Encoder.Drain · Required implementation (no default).

Interface implementation: Required implementation (no default).

Drains pending bytes into a borrowed writable destination.

Parameters

Name Type Description
output Slice<Byte> Destination view, reusable after return; built-ins accept at most 65536 bytes.

Return value

Result<EncoderProgress, EncodingError>

BytesWritten and Ready, NeedsOutput or Finished, or a LimitExceeded/Finished error.

Remarks

The destination is not retained. Only BytesWritten bytes change; the remaining view and surrounding storage are untouched. Excessive capacity leaves output and encoder state unchanged. Empty output can report NeedsOutput with zero progress. Fragments can split a Unicode scalar. Invalid window construction faults before this call.