pub struct Scanner<C: CharSource> { /* private fields */ }
Available on crate feature master only.
Expand description

Reader of master file tokens.

A scanner reads characters from a source and converts them into tokens or errors.

Implementations

Creates a new scanner.

Creates a new scanner using the given character source and position.

The scanner will assume that the current position of chars corresponds to the human-friendly position pos.

Access to Origin

Domain names in a master file that do not end in a dot are relative to some origin. This origin is simply appened to them to form an absolute name.

Since domain names can appear all over the place and we don’t want to have to pass around the origin all the time, it is part of the scanner and can be set and retrieved any time.

Returns the current origin if any.

Sets the origin to the given value.

Returns whether the scanner has reached the end of data.

Returns the current position of the scanner.

Scans a word token.

A word is a sequence of non-special characters and escape sequences followed by a non-empty sequence of space unless it is followed directly by a newline. If successful, the method will position at the end of the space sequence if it is required. That is, you can scan for two subsequent word tokens without worrying about the space between them.

The method starts out with a target value and two closures. The first closure, symbolop, is being fed symbols of the word one by one and should feed them into the target. Once the word ended, the second closure is called to convert the target into the final result. Both can error out at any time stopping processing and leading the scanner to revert to the beginning of the token.

Scans a word with Unicode text into a String.

The method scans a word that consists of characters and puts these into a String. Once the word ends, the caller is given a chance to convert the value into something else via the closure finalop. This closure can fail, resulting in an error and back-tracking to the beginning of the phrase.

Scans a quoted word.

A quoted word starts with a double quote ", followed by all sorts of characters or escape sequences until the next (unescaped) double quote. It may contain line feeds. Like a regular word, a quoted word is followed by a non-empty space sequence unless it is directly followed by a newline. This space is not part of the content but quietly skipped over.

The method starts out with a target value and two closures. The first closure, symbolop, is being fed symbols of the word one by one and should feed them into the target. Once the word ended, the second closure is called to convert the target into the final result. Both can error out at any time stopping processing and leading the scanner to revert to the beginning of the token.

Scans a phrase: a normal word or a quoted word.

This method behaves like scan_quoted() if the next character is a double quote or like scan_word() otherwise.

Scans a phrase with byte content into a Bytes value.

The method scans a phrase that consists of byte only and puts these bytes into a Bytes value. Once the phrase ends, the caller is given a chance to convert the value into something else via the closure finalop. This closure can fail, resulting in an error and back-tracking to the beginning of the phrase.

Scans a phrase with Unicode text into a String.

The method scans a phrase that consists of characters and puts these into a String. Once the phrase ends, the caller is given a chance to convert the value into something else via the closure finalop. This closure can fail, resulting in an error and back-tracking to the beginning of the phrase.

Scans over a mandatory newline.

A newline is either an optional comment followed by a newline sequence or the end of file. The latter is so that a file lacking a line feed after its last line is still parsed successfully.

Scans over a mandatory sequence of space.

There are two flavors of space. The simple form is any sequence of a space character ' ' or a horizontal tab ’\t'. However, a parenthesis can be used to turn newlines into normal space. This method recognises parentheses and acts accordingly.

Scans over an optional sequence of space.

source

pub fn skip_entry(&mut self) -> Result<(), ScanError>

Skips over an entry.

Keeps reading until it successfully scans a newline. The method tries to be smart about that and considers parentheses, quotes, and escapes but also tries its best to not fail.

Skips over the word with the content literal.

The content indeed needs to be literally the literal. Escapes are not translated before comparison and case has to be as is.

Scans a word containing a sequence of pairs of hex digits.

The word is returned as a Bytes value with each byte representing the decoded value of one hex digit pair.

Scans a phrase containing base32hex encoded data.

In particular, this decodes the “base32hex” decoding definied in RFC 4648 without padding.

Scans a sequence of phrases containing base64 encoded data.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.