Writer interfacev0.1.0
Somewhere bytes go.
pub interface Writer {
func Write(
self: &var Self,
bytes: char8[..]
) -> uint ! IoError;
func Flush(self: &var Self) -> ! IoError;
}
Requirements
Write
func Write(
self: &var Self,
bytes: char8[..]
) -> uint ! IoError
Takes what it can of bytes and succeeds with how much.
| Name | Type | Description |
|---|---|---|
bytes | char8[..] | the bytes to write |
Returns: how many bytes were taken, which may be fewer than offered
Flush
func Flush(self: &var Self) -> ! IoError
Pushes whatever is held toward the destination.
Returns: success when everything held reached the destination
Implementations
| Type | Summary |
|---|---|
ByteWriter | A writer that keeps what is written in a growing block of memory. |
StandardOut | Standard output: a byte Writer whose encoding matches where the bytes land. |
StandardError | Standard error: the same contract as standard output, on the stream reports belong to. |
Related
WriteAll
pub func WriteAll(
writer: &var Writer,
bytes: char8[..]
) -> ! IoError
Writes all of bytes, looping over partial writes, or says why it could not.
A writer that accepts nothing while reporting success is refused with WriteZero after a few rounds: a loop
that spins on it would hang the caller on a stream that will never take the rest.
Parameters
| Name | Type | Description |
|---|---|---|
writer | &var Writer | the destination |
bytes | char8[..] | the bytes to write |
Returns: success only when every byte was written, looping over short writes