StringBytes

typeStringBytes

A view into a string indexed by bytes.

functionget(self: StringBytes, idx: u64) Option[char]

Get the character at byte offset idx.

functionlen(self: StringBytes) u64

Get the length of the string in bytes.

functionlist(self: StringBytes) List[u8]

Returns the list of bytes of this string.

functionslice(self: StringBytes, start: u64, end: u64) Option[String]

Slice this string based on byte indices.

The byte at index end is not included in the returned string.

This method returns None if either start or end is out of bounds or if start is greater than end. Additionally, this method also returns None if the resulting string would not be valid UTF-8, i.e. when the one of the indices is within a code point.