Function readSliceEndian [src]

Fill buffer with the next buffer.len bytes from the stream, advancing the seek position. Invalidates previously returned values from peek. If the provided buffer cannot be filled completely, error.EndOfStream is returned instead. The function is inline to avoid the dead code in case endian is comptime-known and matches host endianness. See also: readSliceAll readSliceEndianAlloc

Prototype

pub inline fn readSliceEndian( r: *Reader, comptime Elem: type, buffer: []Elem, endian: std.builtin.Endian, ) Error!void

Parameters

r: *ReaderElem: typebuffer: []Elemendian: std.builtin.Endian

Possible Errors

EndOfStream
ReadFailed

See the Reader implementation for detailed diagnostics.

Source

pub inline fn readSliceEndian( r: *Reader, comptime Elem: type, buffer: []Elem, endian: std.builtin.Endian, ) Error!void { try readSliceAll(r, @ptrCast(buffer)); if (native_endian != endian) for (buffer) |*elem| std.mem.byteSwapAllFields(Elem, elem); }