| author | |
| committer | |
| log | f3a38e30faae2bfd9066dd187e9b4e9f914c46d6 |
| tree | d40ae33084c9f5f4ab8564e4d98d04c359dd51dd |
| parent | 4741a16d9aab40bea8f1cf604337b3de067accb5 |
Alternative is to use File.Reader and File.Writer directly.4 files changed, 1 insertions(+), 70 deletions(-)
lib/std/Io.zig-3| ... | @@ -438,8 +438,6 @@ pub fn GenericWriter( | ... | @@ -438,8 +438,6 @@ pub fn GenericWriter( |
| 438 | pub const AnyReader = @import("Io/DeprecatedReader.zig"); | 438 | pub const AnyReader = @import("Io/DeprecatedReader.zig"); |
| 439 | /// Deprecated in favor of `Writer`. | 439 | /// Deprecated in favor of `Writer`. |
| 440 | pub const AnyWriter = @import("Io/DeprecatedWriter.zig"); | 440 | pub const AnyWriter = @import("Io/DeprecatedWriter.zig"); |
| 441 | /// Deprecated in favor of `File.Reader` and `File.Writer`. | ||
| 442 | pub const SeekableStream = @import("Io/seekable_stream.zig").SeekableStream; | ||
| 443 | /// Deprecated in favor of `Writer`. | 441 | /// Deprecated in favor of `Writer`. |
| 444 | pub const BufferedWriter = @import("Io/buffered_writer.zig").BufferedWriter; | 442 | pub const BufferedWriter = @import("Io/buffered_writer.zig").BufferedWriter; |
| 445 | /// Deprecated in favor of `Writer`. | 443 | /// Deprecated in favor of `Writer`. |
| ... | @@ -948,7 +946,6 @@ test { | ... | @@ -948,7 +946,6 @@ test { |
| 948 | _ = CountingWriter; | 946 | _ = CountingWriter; |
| 949 | _ = CountingReader; | 947 | _ = CountingReader; |
| 950 | _ = FixedBufferStream; | 948 | _ = FixedBufferStream; |
| 951 | _ = SeekableStream; | ||
| 952 | _ = tty; | 949 | _ = tty; |
| 953 | _ = @import("Io/test.zig"); | 950 | _ = @import("Io/test.zig"); |
| 954 | } | 951 | } |
lib/std/Io/fixed_buffer_stream.zig+1-16| ... | @@ -4,8 +4,7 @@ const testing = std.testing; | ... | @@ -4,8 +4,7 @@ const testing = std.testing; |
| 4 | const mem = std.mem; | 4 | const mem = std.mem; |
| 5 | const assert = std.debug.assert; | 5 | const assert = std.debug.assert; |
| 6 | 6 | ||
| 7 | /// This turns a byte buffer into an `io.GenericWriter`, `io.GenericReader`, or `io.SeekableStream`. | 7 | /// Deprecated in favor of `std.Io.Reader.fixed` and `std.Io.Writer.fixed`. |
| 8 | /// If the supplied byte buffer is const, then `io.GenericWriter` is not available. | ||
| 9 | pub fn FixedBufferStream(comptime Buffer: type) type { | 8 | pub fn FixedBufferStream(comptime Buffer: type) type { |
| 10 | return struct { | 9 | return struct { |
| 11 | /// `Buffer` is either a `[]u8` or `[]const u8`. | 10 | /// `Buffer` is either a `[]u8` or `[]const u8`. |
| ... | @@ -20,16 +19,6 @@ pub fn FixedBufferStream(comptime Buffer: type) type { | ... | @@ -20,16 +19,6 @@ pub fn FixedBufferStream(comptime Buffer: type) type { |
| 20 | pub const Reader = io.GenericReader(*Self, ReadError, read); | 19 | pub const Reader = io.GenericReader(*Self, ReadError, read); |
| 21 | pub const Writer = io.GenericWriter(*Self, WriteError, write); | 20 | pub const Writer = io.GenericWriter(*Self, WriteError, write); |
| 22 | 21 | ||
| 23 | pub const SeekableStream = io.SeekableStream( | ||
| 24 | *Self, | ||
| 25 | SeekError, | ||
| 26 | GetSeekPosError, | ||
| 27 | seekTo, | ||
| 28 | seekBy, | ||
| 29 | getPos, | ||
| 30 | getEndPos, | ||
| 31 | ); | ||
| 32 | |||
| 33 | const Self = @This(); | 22 | const Self = @This(); |
| 34 | 23 | ||
| 35 | pub fn reader(self: *Self) Reader { | 24 | pub fn reader(self: *Self) Reader { |
| ... | @@ -40,10 +29,6 @@ pub fn FixedBufferStream(comptime Buffer: type) type { | ... | @@ -40,10 +29,6 @@ pub fn FixedBufferStream(comptime Buffer: type) type { |
| 40 | return .{ .context = self }; | 29 | return .{ .context = self }; |
| 41 | } | 30 | } |
| 42 | 31 | ||
| 43 | pub fn seekableStream(self: *Self) SeekableStream { | ||
| 44 | return .{ .context = self }; | ||
| 45 | } | ||
| 46 | |||
| 47 | pub fn read(self: *Self, dest: []u8) ReadError!usize { | 32 | pub fn read(self: *Self, dest: []u8) ReadError!usize { |
| 48 | const size = @min(dest.len, self.buffer.len - self.pos); | 33 | const size = @min(dest.len, self.buffer.len - self.pos); |
| 49 | const end = self.pos + size; | 34 | const end = self.pos + size; |
lib/std/Io/seekable_stream.zig deleted-35| ... | @@ -1,35 +0,0 @@ | ||
| 1 | const std = @import("../std.zig"); | ||
| 2 | |||
| 3 | pub fn SeekableStream( | ||
| 4 | comptime Context: type, | ||
| 5 | comptime SeekErrorType: type, | ||
| 6 | comptime GetSeekPosErrorType: type, | ||
| 7 | comptime seekToFn: fn (context: Context, pos: u64) SeekErrorType!void, | ||
| 8 | comptime seekByFn: fn (context: Context, pos: i64) SeekErrorType!void, | ||
| 9 | comptime getPosFn: fn (context: Context) GetSeekPosErrorType!u64, | ||
| 10 | comptime getEndPosFn: fn (context: Context) GetSeekPosErrorType!u64, | ||
| 11 | ) type { | ||
| 12 | return struct { | ||
| 13 | context: Context, | ||
| 14 | |||
| 15 | const Self = @This(); | ||
| 16 | pub const SeekError = SeekErrorType; | ||
| 17 | pub const GetSeekPosError = GetSeekPosErrorType; | ||
| 18 | |||
| 19 | pub fn seekTo(self: Self, pos: u64) SeekError!void { | ||
| 20 | return seekToFn(self.context, pos); | ||
| 21 | } | ||
| 22 | |||
| 23 | pub fn seekBy(self: Self, amt: i64) SeekError!void { | ||
| 24 | return seekByFn(self.context, amt); | ||
| 25 | } | ||
| 26 | |||
| 27 | pub fn getEndPos(self: Self) GetSeekPosError!u64 { | ||
| 28 | return getEndPosFn(self.context); | ||
| 29 | } | ||
| 30 | |||
| 31 | pub fn getPos(self: Self) GetSeekPosError!u64 { | ||
| 32 | return getPosFn(self.context); | ||
| 33 | } | ||
| 34 | }; | ||
| 35 | } | ||
lib/std/fs/File.zig-16| ... | @@ -1105,22 +1105,6 @@ pub fn deprecatedWriter(file: File) DeprecatedWriter { | ... | @@ -1105,22 +1105,6 @@ pub fn deprecatedWriter(file: File) DeprecatedWriter { |
| 1105 | return .{ .context = file }; | 1105 | return .{ .context = file }; |
| 1106 | } | 1106 | } |
| 1107 | 1107 | ||
| 1108 | /// Deprecated in favor of `Reader` and `Writer`. | ||
| 1109 | pub const SeekableStream = io.SeekableStream( | ||
| 1110 | File, | ||
| 1111 | SeekError, | ||
| 1112 | GetSeekPosError, | ||
| 1113 | seekTo, | ||
| 1114 | seekBy, | ||
| 1115 | getPos, | ||
| 1116 | getEndPos, | ||
| 1117 | ); | ||
| 1118 | |||
| 1119 | /// Deprecated in favor of `Reader` and `Writer`. | ||
| 1120 | pub fn seekableStream(file: File) SeekableStream { | ||
| 1121 | return .{ .context = file }; | ||
| 1122 | } | ||
| 1123 | |||
| 1124 | /// Memoizes key information about a file handle such as: | 1108 | /// Memoizes key information about a file handle such as: |
| 1125 | /// * The size from calling stat, or the error that occurred therein. | 1109 | /// * The size from calling stat, or the error that occurred therein. |
| 1126 | /// * The current seek position. | 1110 | /// * The current seek position. |