Remove deprecated stream aliases

This commit is contained in:
Jay Petacat 2021-01-08 15:36:02 -05:00
parent 2b3b355a23
commit 1595ce273e
29 changed files with 43 additions and 273 deletions

View File

@ -6120,7 +6120,7 @@ pub fn main() void {
{#code_begin|syntax#}
/// Calls print and then flushes the buffer.
pub fn printf(self: *OutStream, comptime format: []const u8, args: anytype) anyerror!void {
pub fn printf(self: *Writer, comptime format: []const u8, args: anytype) anyerror!void {
const State = enum {
start,
open_brace,
@ -6192,7 +6192,7 @@ pub fn printf(self: *OutStream, comptime format: []const u8, args: anytype) anye
and emits a function that actually looks like this:
</p>
{#code_begin|syntax#}
pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void {
pub fn printf(self: *Writer, arg0: i32, arg1: []const u8) !void {
try self.write("here is a string: '");
try self.printValue(arg0);
try self.write("' here is a number: ");
@ -6206,7 +6206,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void {
on the type:
</p>
{#code_begin|syntax#}
pub fn printValue(self: *OutStream, value: anytype) !void {
pub fn printValue(self: *Writer, value: anytype) !void {
switch (@typeInfo(@TypeOf(value))) {
.Int => {
return self.printInt(T, value);

View File

@ -242,9 +242,6 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
return .{ .context = self };
}
/// Deprecated: use `writer`
pub const outStream = writer;
/// Same as `append` except it returns the number of bytes written, which is always the same
/// as `m.len`. The purpose of this function existing is to match `std.io.Writer` API.
fn appendWrite(self: *Self, m: []const u8) !usize {

View File

@ -232,11 +232,6 @@ pub fn LinearFifo(
return .{ .context = self };
}
/// Deprecated: `use reader`
pub fn inStream(self: *Self) std.io.InStream(*Self, error{}, readFn) {
return .{ .context = self };
}
/// Returns number of items available in fifo
pub fn writableLength(self: Self) usize {
return self.buf.len - self.count;
@ -317,7 +312,7 @@ pub fn LinearFifo(
}
/// Same as `write` except it returns the number of bytes written, which is always the same
/// as `bytes.len`. The purpose of this function existing is to match `std.io.OutStream` API.
/// as `bytes.len`. The purpose of this function existing is to match `std.io.Writer` API.
fn appendWrite(self: *Self, bytes: []const u8) error{OutOfMemory}!usize {
try self.write(bytes);
return bytes.len;
@ -327,11 +322,6 @@ pub fn LinearFifo(
return .{ .context = self };
}
/// Deprecated: `use writer`
pub fn outStream(self: *Self) std.io.OutStream(*Self, error{OutOfMemory}, appendWrite) {
return .{ .context = self };
}
/// Make `count` items available before the current read location
fn rewind(self: *Self, count: usize) void {
assert(self.writableLength() >= count);

View File

@ -813,32 +813,16 @@ pub const File = struct {
pub const Reader = io.Reader(File, ReadError, read);
/// Deprecated: use `Reader`
pub const InStream = Reader;
pub fn reader(file: File) Reader {
return .{ .context = file };
}
/// Deprecated: use `reader`
pub fn inStream(file: File) Reader {
return .{ .context = file };
}
pub const Writer = io.Writer(File, WriteError, write);
/// Deprecated: use `Writer`
pub const OutStream = Writer;
pub fn writer(file: File) Writer {
return .{ .context = file };
}
/// Deprecated: use `writer`
pub fn outStream(file: File) Writer {
return .{ .context = file };
}
pub const SeekableStream = io.SeekableStream(
File,
SeekError,

View File

@ -9,22 +9,22 @@ const Allocator = std.mem.Allocator;
/// This allocator is used in front of another allocator and logs to the provided stream
/// on every call to the allocator. Stream errors are ignored.
/// If https://github.com/ziglang/zig/issues/2586 is implemented, this API can be improved.
pub fn LoggingAllocator(comptime OutStreamType: type) type {
pub fn LoggingAllocator(comptime Writer: type) type {
return struct {
allocator: Allocator,
parent_allocator: *Allocator,
out_stream: OutStreamType,
writer: Writer,
const Self = @This();
pub fn init(parent_allocator: *Allocator, out_stream: OutStreamType) Self {
pub fn init(parent_allocator: *Allocator, writer: Writer) Self {
return Self{
.allocator = Allocator{
.allocFn = alloc,
.resizeFn = resize,
},
.parent_allocator = parent_allocator,
.out_stream = out_stream,
.writer = writer,
};
}
@ -36,12 +36,12 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type {
ra: usize,
) error{OutOfMemory}![]u8 {
const self = @fieldParentPtr(Self, "allocator", allocator);
self.out_stream.print("alloc : {}", .{len}) catch {};
self.writer.print("alloc : {}", .{len}) catch {};
const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra);
if (result) |buff| {
self.out_stream.print(" success!\n", .{}) catch {};
self.writer.print(" success!\n", .{}) catch {};
} else |err| {
self.out_stream.print(" failure!\n", .{}) catch {};
self.writer.print(" failure!\n", .{}) catch {};
}
return result;
}
@ -56,20 +56,20 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type {
) error{OutOfMemory}!usize {
const self = @fieldParentPtr(Self, "allocator", allocator);
if (new_len == 0) {
self.out_stream.print("free : {}\n", .{buf.len}) catch {};
self.writer.print("free : {}\n", .{buf.len}) catch {};
} else if (new_len <= buf.len) {
self.out_stream.print("shrink: {} to {}\n", .{ buf.len, new_len }) catch {};
self.writer.print("shrink: {} to {}\n", .{ buf.len, new_len }) catch {};
} else {
self.out_stream.print("expand: {} to {}", .{ buf.len, new_len }) catch {};
self.writer.print("expand: {} to {}", .{ buf.len, new_len }) catch {};
}
if (self.parent_allocator.resizeFn(self.parent_allocator, buf, buf_align, new_len, len_align, ra)) |resized_len| {
if (new_len > buf.len) {
self.out_stream.print(" success!\n", .{}) catch {};
self.writer.print(" success!\n", .{}) catch {};
}
return resized_len;
} else |e| {
std.debug.assert(new_len > buf.len);
self.out_stream.print(" failure!\n", .{}) catch {};
self.writer.print(" failure!\n", .{}) catch {};
return e;
}
}
@ -78,9 +78,9 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type {
pub fn loggingAllocator(
parent_allocator: *Allocator,
out_stream: anytype,
) LoggingAllocator(@TypeOf(out_stream)) {
return LoggingAllocator(@TypeOf(out_stream)).init(parent_allocator, out_stream);
writer: anytype,
) LoggingAllocator(@TypeOf(writer)) {
return LoggingAllocator(@TypeOf(writer)).init(parent_allocator, writer);
}
test "LoggingAllocator" {

View File

@ -107,26 +107,14 @@ pub fn getStdIn() File {
}
pub const Reader = @import("io/reader.zig").Reader;
/// Deprecated: use `Reader`
pub const InStream = Reader;
pub const Writer = @import("io/writer.zig").Writer;
/// Deprecated: use `Writer`
pub const OutStream = Writer;
pub const SeekableStream = @import("io/seekable_stream.zig").SeekableStream;
pub const BufferedWriter = @import("io/buffered_writer.zig").BufferedWriter;
pub const bufferedWriter = @import("io/buffered_writer.zig").bufferedWriter;
/// Deprecated: use `BufferedWriter`
pub const BufferedOutStream = BufferedWriter;
/// Deprecated: use `bufferedWriter`
pub const bufferedOutStream = bufferedWriter;
pub const BufferedReader = @import("io/buffered_reader.zig").BufferedReader;
pub const bufferedReader = @import("io/buffered_reader.zig").bufferedReader;
/// Deprecated: use `BufferedReader`
pub const BufferedInStream = BufferedReader;
/// Deprecated: use `bufferedReader`
pub const bufferedInStream = bufferedReader;
pub const PeekStream = @import("io/peek_stream.zig").PeekStream;
pub const peekStream = @import("io/peek_stream.zig").peekStream;
@ -136,40 +124,20 @@ pub const fixedBufferStream = @import("io/fixed_buffer_stream.zig").fixedBufferS
pub const CWriter = @import("io/c_writer.zig").CWriter;
pub const cWriter = @import("io/c_writer.zig").cWriter;
/// Deprecated: use `CWriter`
pub const COutStream = CWriter;
/// Deprecated: use `cWriter`
pub const cOutStream = cWriter;
pub const CountingWriter = @import("io/counting_writer.zig").CountingWriter;
pub const countingWriter = @import("io/counting_writer.zig").countingWriter;
pub const CountingReader = @import("io/counting_reader.zig").CountingReader;
pub const countingReader = @import("io/counting_reader.zig").countingReader;
/// Deprecated: use `CountingWriter`
pub const CountingOutStream = CountingWriter;
/// Deprecated: use `countingWriter`
pub const countingOutStream = countingWriter;
pub const MultiWriter = @import("io/multi_writer.zig").MultiWriter;
pub const multiWriter = @import("io/multi_writer.zig").multiWriter;
/// Deprecated: use `MultiWriter`
pub const MultiOutStream = MultiWriter;
/// Deprecated: use `multiWriter`
pub const multiOutStream = multiWriter;
pub const BitReader = @import("io/bit_reader.zig").BitReader;
pub const bitReader = @import("io/bit_reader.zig").bitReader;
/// Deprecated: use `BitReader`
pub const BitInStream = BitReader;
/// Deprecated: use `bitReader`
pub const bitInStream = bitReader;
pub const BitWriter = @import("io/bit_writer.zig").BitWriter;
pub const bitWriter = @import("io/bit_writer.zig").bitWriter;
/// Deprecated: use `BitWriter`
pub const BitOutStream = BitWriter;
/// Deprecated: use `bitWriter`
pub const bitOutStream = bitWriter;
pub const AutoIndentingStream = @import("io/auto_indenting_stream.zig").AutoIndentingStream;
pub const autoIndentingStream = @import("io/auto_indenting_stream.zig").autoIndentingStream;
@ -187,12 +155,7 @@ pub const StreamSource = @import("io/stream_source.zig").StreamSource;
/// A Writer that doesn't write to anything.
pub const null_writer = @as(NullWriter, .{ .context = {} });
/// Deprecated: use `null_writer`
pub const null_out_stream = null_writer;
const NullWriter = Writer(void, error{}, dummyWrite);
/// Deprecated: use NullWriter
const NullOutStream = NullWriter;
fn dummyWrite(context: void, data: []const u8) error{}!usize {
return data.len;
}

View File

@ -1,10 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
/// Deprecated: use `std.io.bit_reader.BitReader`
pub const BitInStream = @import("./bit_reader.zig").BitReader;
/// Deprecated: use `std.io.bit_reader.bitReader`
pub const bitInStream = @import("./bit_reader.zig").bitReader;

View File

@ -1,10 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
/// Deprecated: use `std.io.bit_writer.BitWriter`
pub const BitOutStream = @import("./bit_writer.zig").BitWriter;
/// Deprecated: use `std.io.bit_writer.bitWriter`
pub const bitOutStream = @import("./bit_writer.zig").bitWriter;

View File

@ -21,8 +21,6 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
pub const Error = ReaderType.Error;
pub const Reader = io.Reader(*Self, Error, read);
/// Deprecated: use `Reader`
pub const InStream = io.InStream(*Self, Error, read);
const Self = @This();
const u8_bit_count = comptime meta.bitCount(u8);
@ -165,11 +163,6 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
pub fn reader(self: *Self) Reader {
return .{ .context = self };
}
/// Deprecated: use `reader`
pub fn inStream(self: *Self) InStream {
return .{ .context = self };
}
};
}

View File

@ -21,8 +21,6 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
pub const Error = WriterType.Error;
pub const Writer = io.Writer(*Self, Error, write);
/// Deprecated: use `Writer`
pub const OutStream = io.OutStream(*Self, Error, write);
const Self = @This();
const u8_bit_count = comptime meta.bitCount(u8);
@ -141,10 +139,6 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
pub fn writer(self: *Self) Writer {
return .{ .context = self };
}
/// Deprecated: use `writer`
pub fn outStream(self: *Self) OutStream {
return .{ .context = self };
}
};
}

View File

@ -10,13 +10,13 @@ const File = std.fs.File;
pub const BufferedAtomicFile = struct {
atomic_file: fs.AtomicFile,
file_stream: File.OutStream,
buffered_stream: BufferedOutStream,
file_writer: File.Writer,
buffered_writer: BufferedWriter,
allocator: *mem.Allocator,
pub const buffer_size = 4096;
pub const BufferedOutStream = std.io.BufferedOutStream(buffer_size, File.OutStream);
pub const OutStream = std.io.OutStream(*BufferedOutStream, BufferedOutStream.Error, BufferedOutStream.write);
pub const BufferedWriter = std.io.BufferedWriter(buffer_size, File.Writer);
pub const Writer = std.io.Writer(*BufferedWriter, BufferedWriter.Error, BufferedWriter.write);
/// TODO when https://github.com/ziglang/zig/issues/2761 is solved
/// this API will not need an allocator
@ -29,8 +29,8 @@ pub const BufferedAtomicFile = struct {
var self = try allocator.create(BufferedAtomicFile);
self.* = BufferedAtomicFile{
.atomic_file = undefined,
.file_stream = undefined,
.buffered_stream = undefined,
.file_writer = undefined,
.buffered_writer = undefined,
.allocator = allocator,
};
errdefer allocator.destroy(self);
@ -38,8 +38,8 @@ pub const BufferedAtomicFile = struct {
self.atomic_file = try dir.atomicFile(dest_path, atomic_file_options);
errdefer self.atomic_file.deinit();
self.file_stream = self.atomic_file.file.writer();
self.buffered_stream = .{ .unbuffered_writer = self.file_stream };
self.file_writer = self.atomic_file.file.writer();
self.buffered_writer = .{ .unbuffered_writer = self.file_writer };
return self;
}
@ -50,11 +50,11 @@ pub const BufferedAtomicFile = struct {
}
pub fn finish(self: *BufferedAtomicFile) !void {
try self.buffered_stream.flush();
try self.buffered_writer.flush();
try self.atomic_file.finish();
}
pub fn stream(self: *BufferedAtomicFile) OutStream {
return .{ .context = &self.buffered_stream };
pub fn writer(self: *BufferedAtomicFile) Writer {
return .{ .context = &self.buffered_writer };
}
};

View File

@ -1,10 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
/// Deprecated: use `std.io.buffered_reader.BufferedReader`
pub const BufferedInStream = @import("./buffered_reader.zig").BufferedReader;
/// Deprecated: use `std.io.buffered_reader.bufferedReader`
pub const bufferedInStream = @import("./buffered_reader.zig").bufferedReader;

View File

@ -1,10 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
/// Deprecated: use `std.io.buffered_writer.BufferedWriter`
pub const BufferedOutStream = @import("./buffered_writer.zig").BufferedWriter;
/// Deprecated: use `std.io.buffered_writer.bufferedWriter`
pub const bufferedOutStream = @import("./buffered_writer.zig").bufferedWriter;

View File

@ -15,8 +15,6 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty
pub const Error = ReaderType.Error;
pub const Reader = io.Reader(*Self, Error, read);
/// Deprecated: use `Reader`
pub const InStream = Reader;
const Self = @This();
const FifoType = std.fifo.LinearFifo(u8, std.fifo.LinearFifoBufferType{ .Static = buffer_size });
@ -45,11 +43,6 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty
pub fn reader(self: *Self) Reader {
return .{ .context = self };
}
/// Deprecated: use `reader`
pub fn inStream(self: *Self) InStream {
return .{ .context = self };
}
};
}

View File

@ -13,8 +13,6 @@ pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) ty
pub const Error = WriterType.Error;
pub const Writer = io.Writer(*Self, Error, write);
/// Deprecated: use `Writer`
pub const OutStream = Writer;
const Self = @This();
const FifoType = std.fifo.LinearFifo(u8, std.fifo.LinearFifoBufferType{ .Static = buffer_size });
@ -32,11 +30,6 @@ pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) ty
return .{ .context = self };
}
/// Deprecated: use writer
pub fn outStream(self: *Self) Writer {
return .{ .context = self };
}
pub fn write(self: *Self, bytes: []const u8) Error!usize {
if (bytes.len >= self.fifo.writableLength()) {
try self.flush();

View File

@ -1,10 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
/// Deprecated: use `std.io.c_writer.CWriter`
pub const COutStream = @import("./c_writer.zig").CWriter;
/// Deprecated: use `std.io.c_writer.cWriter`
pub const cOutStream = @import("./c_writer.zig").cWriter;

View File

@ -1,10 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
/// Deprecated: use `std.io.counting_writer.CountingWriter`
pub const CountingOutStream = @import("./counting_writer.zig").CountingWriter;
/// Deprecated: use `std.io.counting_writer.countingWriter`
pub const countingOutStream = @import("./counting_writer.zig").countingWriter;

View File

@ -15,8 +15,6 @@ pub fn CountingWriter(comptime WriterType: type) type {
pub const Error = WriterType.Error;
pub const Writer = io.Writer(*Self, Error, write);
/// Deprecated: use `Writer`
pub const OutStream = Writer;
const Self = @This();
@ -29,11 +27,6 @@ pub fn CountingWriter(comptime WriterType: type) type {
pub fn writer(self: *Self) Writer {
return .{ .context = self };
}
/// Deprecated: use `writer`
pub fn outStream(self: *Self) OutStream {
return .{ .context = self };
}
};
}

View File

@ -23,11 +23,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
pub const GetSeekPosError = error{};
pub const Reader = io.Reader(*Self, ReadError, read);
/// Deprecated: use `Reader`
pub const InStream = io.InStream(*Self, ReadError, read);
pub const Writer = io.Writer(*Self, WriteError, write);
/// Deprecated: use `Writer`
pub const OutStream = Writer;
pub const SeekableStream = io.SeekableStream(
*Self,
@ -45,20 +41,10 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
return .{ .context = self };
}
/// Deprecated: use `reader`
pub fn inStream(self: *Self) InStream {
return .{ .context = self };
}
pub fn writer(self: *Self) Writer {
return .{ .context = self };
}
/// Deprecated: use `writer`
pub fn outStream(self: *Self) OutStream {
return .{ .context = self };
}
pub fn seekableStream(self: *Self) SeekableStream {
return .{ .context = self };
}

View File

@ -1,7 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
/// Deprecated: use `std.io.reader.Reader`
pub const InStream = @import("./reader.zig").Reader;

View File

@ -1,10 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
/// Deprecated: use `std.io.multi_writer.MultiWriter`
pub const MultiOutStream = @import("./multi_writer.zig").MultiWriter;
/// Deprecated: use `std.io.multi_writer.multiWriter`
pub const multiOutStream = @import("./multi_writer.zig").multiWriter;

View File

@ -22,18 +22,11 @@ pub fn MultiWriter(comptime Writers: type) type {
pub const Error = ErrSet;
pub const Writer = io.Writer(*Self, Error, write);
/// Deprecated: use `Writer`
pub const OutStream = Writer;
pub fn writer(self: *Self) Writer {
return .{ .context = self };
}
/// Deprecated: use `writer`
pub fn outStream(self: *Self) OutStream {
return .{ .context = self };
}
pub fn write(self: *Self, bytes: []const u8) Error!usize {
var batch = std.event.Batch(Error!void, self.streams.len, .auto_async).init();
comptime var i = 0;

View File

@ -1,7 +0,0 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
/// Deprecated: use `std.io.writer.Writer`
pub const OutStream = @import("./writer.zig").Writer;

View File

@ -16,13 +16,11 @@ pub fn PeekStream(
comptime ReaderType: type,
) type {
return struct {
unbuffered_in_stream: ReaderType,
unbuffered_reader: ReaderType,
fifo: FifoType,
pub const Error = ReaderType.Error;
pub const Reader = io.Reader(*Self, Error, read);
/// Deprecated: use `Reader`
pub const InStream = Reader;
const Self = @This();
const FifoType = std.fifo.LinearFifo(u8, buffer_type);
@ -31,7 +29,7 @@ pub fn PeekStream(
.Static => struct {
pub fn init(base: ReaderType) Self {
return .{
.unbuffered_in_stream = base,
.unbuffered_reader = base,
.fifo = FifoType.init(),
};
}
@ -39,7 +37,7 @@ pub fn PeekStream(
.Slice => struct {
pub fn init(base: ReaderType, buf: []u8) Self {
return .{
.unbuffered_in_stream = base,
.unbuffered_reader = base,
.fifo = FifoType.init(buf),
};
}
@ -47,7 +45,7 @@ pub fn PeekStream(
.Dynamic => struct {
pub fn init(base: ReaderType, allocator: *mem.Allocator) Self {
return .{
.unbuffered_in_stream = base,
.unbuffered_reader = base,
.fifo = FifoType.init(allocator),
};
}
@ -68,18 +66,13 @@ pub fn PeekStream(
if (dest_index == dest.len) return dest_index;
// ask the backing stream for more
dest_index += try self.unbuffered_in_stream.read(dest[dest_index..]);
dest_index += try self.unbuffered_reader.read(dest[dest_index..]);
return dest_index;
}
pub fn reader(self: *Self) Reader {
return .{ .context = self };
}
/// Deprecated: use `reader`
pub fn inStream(self: *Self) InStream {
return .{ .context = self };
}
};
}

View File

@ -9,7 +9,7 @@ const testing = std.testing;
/// Provides `io.Reader`, `io.Writer`, and `io.SeekableStream` for in-memory buffers as
/// well as files.
/// For memory sources, if the supplied byte buffer is const, then `io.OutStream` is not available.
/// For memory sources, if the supplied byte buffer is const, then `io.Writer` is not available.
/// The error set of the stream functions is the error set of the corresponding file functions.
pub const StreamSource = union(enum) {
buffer: io.FixedBufferStream([]u8),
@ -22,11 +22,7 @@ pub const StreamSource = union(enum) {
pub const GetSeekPosError = std.fs.File.GetPosError;
pub const Reader = io.Reader(*StreamSource, ReadError, read);
/// Deprecated: use `Reader`
pub const InStream = Reader;
pub const Writer = io.Writer(*StreamSource, WriteError, write);
/// Deprecated: use `Writer`
pub const OutStream = Writer;
pub const SeekableStream = io.SeekableStream(
*StreamSource,
SeekError,
@ -89,20 +85,10 @@ pub const StreamSource = union(enum) {
return .{ .context = self };
}
/// Deprecated: use `reader`
pub fn inStream(self: *StreamSource) InStream {
return .{ .context = self };
}
pub fn writer(self: *StreamSource) Writer {
return .{ .context = self };
}
/// Deprecated: use `writer`
pub fn outStream(self: *StreamSource) OutStream {
return .{ .context = self };
}
pub fn seekableStream(self: *StreamSource) SeekableStream {
return .{ .context = self };
}

View File

@ -2620,9 +2620,9 @@ pub fn stringify(
}
fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions) !void {
const ValidationOutStream = struct {
const ValidationWriter = struct {
const Self = @This();
pub const OutStream = std.io.OutStream(*Self, Error, write);
pub const Writer = std.io.Writer(*Self, Error, write);
pub const Error = error{
TooMuchData,
DifferentData,
@ -2634,7 +2634,7 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions
return .{ .expected_remaining = exp };
}
pub fn outStream(self: *Self) OutStream {
pub fn writer(self: *Self) Writer {
return .{ .context = self };
}
@ -2670,8 +2670,8 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions
}
};
var vos = ValidationOutStream.init(expected);
try stringify(value, options, vos.outStream());
var vos = ValidationWriter.init(expected);
try stringify(value, options, vos.writer());
if (vos.expected_remaining.len > 0) return error.NotEnoughData;
}

View File

@ -716,8 +716,4 @@ const MsfStream = struct {
pub fn reader(self: *MsfStream) std.io.Reader(*MsfStream, Error, read) {
return .{ .context = self };
}
/// Deprecated: use `reader`
pub fn inStream(self: *MsfStream) std.io.InStream(*MsfStream, Error, read) {
return .{ .context = self };
}
};

View File

@ -791,7 +791,7 @@ fn renderExpression(
// Null stream for counting the printed length of each expression
var line_find_stream = std.io.findByteOutStream('\n', std.io.null_writer);
var counting_stream = std.io.countingOutStream(line_find_stream.writer());
var counting_stream = std.io.countingWriter(line_find_stream.writer());
var auto_indenting_stream = std.io.autoIndentingStream(indent_delta, counting_stream.writer());
// Calculate size of columns in current section

View File

@ -2015,7 +2015,7 @@ fn updateModule(gpa: *Allocator, comp: *Compilation, zir_out_path: ?[]const u8,
const baf = try io.BufferedAtomicFile.create(gpa, fs.cwd(), zop, .{});
defer baf.destroy();
try new_zir_module.writeToStream(gpa, baf.stream());
try new_zir_module.writeToStream(gpa, baf.writer());
try baf.finish();
}