Writer interfacev0.1.0
pub interface Writer {
func Write(
&var self,
bytes: char8[..]
) -> uint throws IoError;
func Flush(&var self) throws IoError;
}
Requirements
Write
func Write(
&var self,
bytes: char8[..]
) -> uint throws 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(&var self) throws 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[..]
) throws IoError
Writes all of bytes, looping over partial writes, or says why it could not.
Interruptions are retried at once. A writer that accepts nothing while reporting success is refused with
WriteZero after ZeroProgressLimit rounds: a loop that spins on it would hang the caller on a stream that will
never take the rest. Any other failure, WouldBlock included, is returned as itself, with some of bytes
possibly written and how much not reported: a caller writing to a non-blocking stream writes incrementally with
Write.
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