struct VTable [src]

Fields

drain: *const fn (w: *Writer, data: []const []const u8, splat: usize) Error!usizeSends bytes to the logical sink. A write will only be sent here if it could not fit into buffer, or during a flush operation. buffer[0..end] is consumed first, followed by each slice of data in order. Elements of data may alias each other but may not alias buffer. This function modifies Writer.end and Writer.buffer in an implementation-defined manner. data.len must be nonzero. The last element of data is repeated as necessary so that it is written splat number of times, which may be zero. This function may not be called if the data to be written could have been stored in buffer instead, including when the amount of data to be written is zero and the buffer capacity is zero. Number of bytes consumed from data is returned, excluding bytes from buffer. Number of bytes returned may be zero, which does not indicate stream end. A subsequent call may return nonzero, or signal end of stream via error.WriteFailed.
sendFile: *const fn ( w: *Writer, file_reader: *File.Reader, /// Maximum amount of bytes to read from the file. Implementations may /// assume that the file size does not exceed this amount. Data from /// `buffer` does not count towards this limit. limit: Limit, ) FileError!usize = unimplementedSendFileCopies contents from an open file to the logical sink. buffer[0..end] is consumed first, followed by limit bytes from file_reader. Number of bytes logically written is returned. This excludes bytes from buffer because they have already been logically written. Number of bytes consumed from buffer are tracked by modifying end. Number of bytes returned may be zero, which does not indicate stream end. A subsequent call may return nonzero, or signal end of stream via error.WriteFailed. Caller may check file_reader state (File.Reader.atEnd) to disambiguate between a zero-length read or write, and whether the file reached the end. error.Unimplemented indicates the callee cannot offer a more efficient implementation than the caller performing its own reads.
flush: *const fn (w: *Writer) Error!void = defaultFlushConsumes all remaining buffer. The default flush implementation calls drain repeatedly until end is zero, however it is legal for implementations to manage end differently. For instance, Allocating flush is a no-op. There may be subsequent calls to drain and sendFile after a flush operation.
rebase: *const fn (w: *Writer, preserve: usize, capacity: usize) Error!void = defaultRebaseEnsures capacity more bytes can be buffered without rebasing. The most recent preserve bytes must remain buffered. Only called when capacity bytes cannot fit into the unused capacity of buffer.

Source

pub const VTable = struct { /// Sends bytes to the logical sink. A write will only be sent here if it /// could not fit into `buffer`, or during a `flush` operation. /// /// `buffer[0..end]` is consumed first, followed by each slice of `data` in /// order. Elements of `data` may alias each other but may not alias /// `buffer`. /// /// This function modifies `Writer.end` and `Writer.buffer` in an /// implementation-defined manner. /// /// `data.len` must be nonzero. /// /// The last element of `data` is repeated as necessary so that it is /// written `splat` number of times, which may be zero. /// /// This function may not be called if the data to be written could have /// been stored in `buffer` instead, including when the amount of data to /// be written is zero and the buffer capacity is zero. /// /// Number of bytes consumed from `data` is returned, excluding bytes from /// `buffer`. /// /// Number of bytes returned may be zero, which does not indicate stream /// end. A subsequent call may return nonzero, or signal end of stream via /// `error.WriteFailed`. drain: *const fn (w: *Writer, data: []const []const u8, splat: usize) Error!usize, /// Copies contents from an open file to the logical sink. `buffer[0..end]` /// is consumed first, followed by `limit` bytes from `file_reader`. /// /// Number of bytes logically written is returned. This excludes bytes from /// `buffer` because they have already been logically written. Number of /// bytes consumed from `buffer` are tracked by modifying `end`. /// /// Number of bytes returned may be zero, which does not indicate stream /// end. A subsequent call may return nonzero, or signal end of stream via /// `error.WriteFailed`. Caller may check `file_reader` state /// (`File.Reader.atEnd`) to disambiguate between a zero-length read or /// write, and whether the file reached the end. /// /// `error.Unimplemented` indicates the callee cannot offer a more /// efficient implementation than the caller performing its own reads. sendFile: *const fn ( w: *Writer, file_reader: *File.Reader, /// Maximum amount of bytes to read from the file. Implementations may /// assume that the file size does not exceed this amount. Data from /// `buffer` does not count towards this limit. limit: Limit, ) FileError!usize = unimplementedSendFile, /// Consumes all remaining buffer. /// /// The default flush implementation calls drain repeatedly until `end` is /// zero, however it is legal for implementations to manage `end` /// differently. For instance, `Allocating` flush is a no-op. /// /// There may be subsequent calls to `drain` and `sendFile` after a `flush` /// operation. flush: *const fn (w: *Writer) Error!void = defaultFlush, /// Ensures `capacity` more bytes can be buffered without rebasing. /// /// The most recent `preserve` bytes must remain buffered. /// /// Only called when `capacity` bytes cannot fit into the unused capacity /// of `buffer`. rebase: *const fn (w: *Writer, preserve: usize, capacity: usize) Error!void = defaultRebase, }