Add pinned std.io.reader and std.io.writer using safe source, explicit fixed allocation and file transfer. Finish/discard return complete resources; writer failures preserve pending data and prohibit unsound partial retries. Specify cursor, acceptance, failure and cleanup contracts in spec 16, RFC 0034, the API reference and source bundle. Add standalone conformance, independent byte oracles, task/GC stress, CLI/package/profile checks and hosted partial-write tests with a raised child quota to detect retries. Validation: 1061 conformance cases; 34 buffered cases with per-step GC and 12 schedule seeds; unit/Quick Reference, formatting, hosted smoke, 89 CLI checks, 115 source coverage constructs and reference generation.
28 lines
1.8 KiB
Rust
28 lines
1.8 KiB
Rust
// expect: reject E4002
|
|
// phase: 6
|
|
// spec: docs/spec/16-standard-library.md §2.18
|
|
module test.buffered
|
|
import std.io;
|
|
import std.io.reader;
|
|
import std.io.writer;
|
|
import std.option;
|
|
fn reader(file: file<read>,capacity: usize,heap: cap<mem.alloc>) -> std.io.reader.Reader effects [mem.alloc] {
|
|
match std.io.reader.new(move file,capacity,heap) { std.io.reader.NewResult::ok(value) => { return move value; }, std.io.reader.NewResult::err(error) => { trap; } }
|
|
}
|
|
fn writer(file: file<write>,capacity: usize,heap: cap<mem.alloc>) -> std.io.writer.Writer effects [mem.alloc] {
|
|
match std.io.writer.new(move file,capacity,heap) { std.io.writer.NewResult::ok(value) => { return move value; }, std.io.writer.NewResult::err(error) => { trap; } }
|
|
}
|
|
fn exact(result: std.io.ReadExactResult) -> void effects [] {
|
|
match result { std.io.ReadExactResult::ok => {}, std.io.ReadExactResult::eof(count) => { trap; }, std.io.ReadExactResult::err(error) => { trap; } }
|
|
}
|
|
fn written(result: std.io.writer.WriteResult) -> void effects [] { match result { std.io.writer.WriteResult::ok => {}, std.io.writer.WriteResult::err(error) => { trap; } } }
|
|
fn finished_reader(value: std.io.reader.Reader) -> file<read> effects [] {
|
|
match std.io.reader.finish(move value) { std.io.reader.FinishResult::ok(file) => { return move file; }, std.io.reader.FinishResult::unread(value) => { trap; } }
|
|
}
|
|
fn finished_writer(value: std.io.writer.Writer) -> file<write> effects [fs.write] {
|
|
match std.io.writer.finish(move value) { std.io.writer.FinishResult::ok(file) => { return move file; }, std.io.writer.FinishResult::err(error) => { trap; } }
|
|
}
|
|
fn worker(q: ref<std.io.writer.Writer>) -> void effects [] {}
|
|
fn bad(q: ref<std.io.writer.Writer>) -> void effects [task.spawn,task.wait] { scope s { let t = task.spawn(s,worker,q); task.join(move t); } }
|
|
fn main() -> u64 effects [] { return 42; }
|