Display interfacev0.1.0
pub interface Display {
func WriteDisplay(
writer: &var TextWriter,
spec: FormatSpec
) -> ! FormatError;
}
An implementation writes into the destination it is handed and allocates no working storage of its own. A value whose rendering genuinely requires scratch space takes an allocator through a separate, explicit conversion instead of implementing this.
Requirements
WriteDisplay
func WriteDisplay(
writer: &var TextWriter,
spec: FormatSpec
) -> ! FormatError
Writes this value's text under spec.
Returns whatever the writer reported, or UnsupportedRequest when spec asks for something this value does
not support, or ValueOutOfRange when the value cannot be represented in the form requested. An
implementation stops at the first failed write rather than continuing to a destination that has already
refused something.
| Name | Type | Description |
|---|---|---|
writer | &var TextWriter | the destination |
spec | FormatSpec | what the placeholder asked for |
Returns: success when the value's complete text was accepted
Implementations
| Type | Summary |
|---|---|
TextFailureKind | The ways text handling fails, with no case for success. |
FormatError | Why a formatting operation did not produce the text it was asked for. |
String | Text that owns its bytes. |
StringView | A borrowed run of bytes that has been checked to be UTF-8. |
TextError | What went wrong. |
Utf8Error | What was wrong with a byte sequence. |
Related
WriteValue
pub func WriteValue(
writer: &var TextWriter,
value: Display,
spec: FormatSpec
) -> ! FormatError
Writes value under spec through its Display implementation.
A named entry point for rendering one value, so a caller with a value and a writer needs no placeholder pattern
to put them together.
Parameters
| Name | Type | Description |
|---|---|---|
writer | &var TextWriter | the destination |
value | Display | the value to render, borrowed for the call |
spec | FormatSpec | what to render it under |
Returns: whatever the value's implementation reported