Skip to content

schveiguy/io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b9b62cb · Sep 19, 2023

History

71 Commits
Sep 17, 2023
Mar 14, 2021
Oct 29, 2017
Oct 29, 2017
Jul 25, 2020
Jul 26, 2020
Oct 29, 2017
May 11, 2018
Sep 17, 2023
May 11, 2018
Jul 27, 2020
Nov 7, 2019
Mar 14, 2021

Repository files navigation

Logo

Build Status Build Status codecov

Documentation std.io

IOs are thin, OS-independent abstractions over I/O devices.

size_t write(const scope ubyte[] buffer);
size_t read(scope ubyte[] buffer);

IOs support scatter/gather read/write.

size_t write(const scope ubyte[][] buffers...);
size_t read(scope ubyte[][] buffers...);

IOs are @safe and @nogc.

void read() @safe @nogc
{
    auto f = File(chainPath("tmp", "file.txt"));
    ubyte[128] buf;
    f.read(buf[]);
    // ...
}

IOs use exceptions for error handling.

try
    File("");
catch (IOException e)
{}

IOs use unique ownership and are moveable but not copyable (Use refCounted for shared ownership).

io2 = io.move;
assert(io2.isOpen);
assert(!io.isOpen);

auto rc = refCounted(io2.move);
auto rc2 = rc;
assert(rc.isOpen);
assert(rc2.isOpen);

IOs can be converted to polymorphic interfaces if necessary.

Input input = ioObject(io.move);