[][src]Crate rut

Rut

Rut is a small UTF-8 parsing library for applications that need to parse individual chars.
It provides a byte-wise parsing mechanism, and functions for processing byte slices.

It is completely #[no_std] and should produce very small binaries.[citation needed]

Conformance

Rut aims to be fully conformant to the specifications and restrictions of the Unicode standard.
Due to the nature of byte-wise parsing, some extra caution might be required when using Rut.

The parse_one and parse functions take care of this.

Testing

A few tests validating the expected behavior are already in place, but it is not comprehensive by any means yet. More tests will be added.

Examples

use rut::Utf8Parser;

// UTF-8 encoding of '€'
let bytes = [0xE2, 0x82, 0xAC];

let mut p = Utf8Parser::new();
 
assert_eq!(p.parse_byte(bytes[0]), Ok(None));
assert_eq!(p.parse_byte(bytes[1]), Ok(None));
assert_eq!(p.parse_byte(bytes[2]), Ok(Some('€')));

Structs

Parse

An iterator for parsing UTF-8 sequences from a byte slice.

Utf8Parser

A byte-wise UTF-8 parser.

Enums

Utf8ParseError

A UTF-8 parser error.

Functions

parse

Creates an iterator for parsing UTF-8 sequences from a byte slice.

parse_one

Parses one UTF-8 sequence from a byte slice, returning a Result and the unparsed remainder of the slice.