@@ -1194,11 +1194,16 @@ pub const Reader = struct {
11941194 };
11951195 }
11961196
1197- pub fn initMode (file : File , buffer : []u8 , init_mode : Reader.Mode ) Reader {
1197+ /// Positional is more threadsafe, since the global seek position is not
1198+ /// affected, but when such syscalls are not available, preemptively
1199+ /// initializing in streaming mode skips a failed syscall.
1200+ pub fn initStreaming (file : File , buffer : []u8 ) Reader {
11981201 return .{
11991202 .file = file ,
1200- .interface = initInterface (buffer ),
1201- .mode = init_mode ,
1203+ .interface = Reader .initInterface (buffer ),
1204+ .mode = .streaming ,
1205+ .seek_err = error .Unseekable ,
1206+ .size_err = error .Streaming ,
12021207 };
12031208 }
12041209
@@ -1578,14 +1583,21 @@ pub const Writer = struct {
15781583 const max_buffers_len = 16 ;
15791584
15801585 pub fn init (file : File , buffer : []u8 ) Writer {
1581- return initMode (file , buffer , .positional );
1586+ return .{
1587+ .file = file ,
1588+ .interface = initInterface (buffer ),
1589+ .mode = .positional ,
1590+ };
15821591 }
15831592
1584- pub fn initMode (file : File , buffer : []u8 , init_mode : Writer.Mode ) Writer {
1593+ /// Positional is more threadsafe, since the global seek position is not
1594+ /// affected, but when such syscalls are not available, preemptively
1595+ /// initializing in streaming mode will skip a failed syscall.
1596+ pub fn initStreaming (file : File , buffer : []u8 ) Writer {
15851597 return .{
15861598 .file = file ,
15871599 .interface = initInterface (buffer ),
1588- .mode = init_mode ,
1600+ .mode = .streaming ,
15891601 };
15901602 }
15911603
@@ -2092,15 +2104,10 @@ pub fn reader(file: File, buffer: []u8) Reader {
20922104}
20932105
20942106/// Positional is more threadsafe, since the global seek position is not
2095- /// affected, but when such syscalls are not available, preemptively choosing
2096- /// `Reader.Mode. streaming` will skip a failed syscall.
2107+ /// affected, but when such syscalls are not available, preemptively
2108+ /// initializing in streaming mode skips a failed syscall.
20972109pub fn readerStreaming (file : File , buffer : []u8 ) Reader {
2098- return .{
2099- .file = file ,
2100- .interface = Reader .initInterface (buffer ),
2101- .mode = .streaming ,
2102- .seek_err = error .Unseekable ,
2103- };
2110+ return .initStreaming (file , buffer );
21042111}
21052112
21062113/// Defaults to positional reading; falls back to streaming.
@@ -2112,10 +2119,10 @@ pub fn writer(file: File, buffer: []u8) Writer {
21122119}
21132120
21142121/// Positional is more threadsafe, since the global seek position is not
2115- /// affected, but when such syscalls are not available, preemptively choosing
2116- /// `Writer.Mode. streaming` will skip a failed syscall.
2122+ /// affected, but when such syscalls are not available, preemptively
2123+ /// initializing in streaming mode will skip a failed syscall.
21172124pub fn writerStreaming (file : File , buffer : []u8 ) Writer {
2118- return .initMode (file , buffer , .streaming );
2125+ return .initStreaming (file , buffer );
21192126}
21202127
21212128const range_off : windows.LARGE_INTEGER = 0 ;
0 commit comments