v0.4.0

Utf8Error enumv0.1.0

Source
What was wrong with a byte sequence.
pub enum Utf8Error: int32 {
    Truncated = 1,
    InvalidStart = 2,
    InvalidContinuation = 3
}

The cases are distinguished because they mean different things about where the bytes came from. Truncated is what a buffer boundary looks like and may just mean read more; the rest mean the bytes are not UTF-8 and no amount of reading will change that. Every case is a failure: the functions here report success through what they return, and throw this.

Cases

NameValueDescription
Truncated1A sequence starts but the bytes run out before it ends.
InvalidStart2A byte that cannot start a sequence: a continuation byte on its own, or one of the values UTF-8 never uses.
InvalidContinuation3A byte where a continuation byte was required, or a continuation outside the range this leading byte allows — which is what rejects an overlong form, a surrogate half, or a value past the last scalar.

Implements Display

Utf8Error conforms to Display.

WriteDisplay

pub func WriteDisplay(
    &self,
    writer: &var TextWriter,
    spec: FormatSpec
) throws FormatError

Writes the description of what is wrong with a byte sequence, or well-formed UTF-8 for success. Reports whatever the writer reported, and UnsupportedRequest for any style or precision.

NameTypeDescription
writer&var TextWriterthe destination
specFormatSpecwhat the placeholder asked for

Returns: success when the whole description was accepted

Source

Implements Debug

Utf8Error conforms to Debug.

WriteDebug

pub func WriteDebug(
    &self,
    writer: &var TextWriter,
    spec: FormatSpec
) throws FormatError

Names the case, qualified by its type: Utf8Error::Truncated. Reports whatever the writer reported, and UnsupportedRequest for any style or precision.

NameTypeDescription
writer&var TextWriterthe destination
specFormatSpecwhat the placeholder asked for

Returns: success when the whole name was accepted

Source