Struct uclicious::raw::parser::Parser[][src]

pub struct Parser { /* fields omitted */ }
Expand description

Raw parser object.

Implementations

Create a new parser with given option flags.

Add a chunk of text to the parser. String must:

  • not have \0 character;
  • must be valid UCL object;

Add a file by a file path to the parser. This function uses mmap call to load file, therefore, it should not be shrunk during parsing.

Add the standard file variables to the parser based on the filename specified:

  • $FILENAME- a filename of ucl input
  • $CURDIR - a current directory of the input

For example, if a filename param is ../something.conf then the variables will have the following values:

  • $FILENAME - ../something.conf
  • $CURDIR - ..

if need_expand parameter is true then all relative paths are expanded using realpath call. In this example if .. is /etc/dir then variables will have these values:

  • $FILENAME - /etc/something.conf
  • $CURDIR - /etc

Get a top object for a parser.

Register new variable $var that should be replaced by the parser to the value string. Variables need to be registered before they are referenced.

Panics

This function panics if either var or value has \0.

Register function as an unknown variable handler. Parser can only have one handler.

  • handler - a function pointer
  • ud - an opaque pointer that will be passed to a handler
Safety

Both object behind ud and function behind handler need to live at least as long as the parser.

A safe counterpart of Parser::set_variable_handler_raw. Unlike unsafe version this one takes ownership of a handler and ensures it stays alive as long as parser does.

Caveats

Parser can have only bar handler. In order to have multiple, please use CompoundHandler to join multiple handlers into one.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Executes the destructor for this type. 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

Performs the conversion.

Performs the conversion.

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.