https://github.com/schveiguy/io
Core I/O functionality
https://github.com/schveiguy/io
dlang dub io nogc safe
Last synced: 2 months ago
JSON representation
Core I/O functionality
- Host: GitHub
- URL: https://github.com/schveiguy/io
- Owner: schveiguy
- License: bsl-1.0
- Created: 2017-10-13T18:25:58.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-17T18:22:08.000Z (over 1 year ago)
- Last Synced: 2025-03-12T02:06:07.122Z (2 months ago)
- Topics: dlang, dub, io, nogc, safe
- Language: D
- Size: 247 KB
- Stars: 25
- Watchers: 6
- Forks: 9
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## [](https://travis-ci.org/MartinNowak/io) [](https://ci.appveyor.com/project/MartinNowak/io) [](https://codecov.io/gh/MartinNowak/io)
## Documentation [std.io](https://martinnowak.github.io/io/std/io)
IOs are thin, OS-independent abstractions over I/O devices.
```d
size_t write(const scope ubyte[] buffer);
size_t read(scope ubyte[] buffer);
```IOs support [scatter/gather read/write](https://en.wikipedia.org/wiki/Vectored_I/O).
```d
size_t write(const scope ubyte[][] buffers...);
size_t read(scope ubyte[][] buffers...);
```IOs are `@safe` and `@nogc`.
```d
void read() @safe @nogc
{
auto f = File(chainPath("tmp", "file.txt"));
ubyte[128] buf;
f.read(buf[]);
// ...
}
```IOs use exceptions for error handling.
```d
try
File("");
catch (IOException e)
{}
```IOs use unique ownership and are [moveable](https://dlang.org/phobos/std_algorithm_mutation.html#.move) but not copyable (Use [refCounted](https://dlang.org/phobos/std_typecons.html#refCounted) for shared ownership).
```d
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.
```d
Input input = ioObject(io.move);
```